From 2ee5991b42717969af93cb30d863aafab04dff8a Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 20 Jan 2020 09:08:32 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .gitlab/issue_templates/Feature proposal.md | 11 +- .rubocop.yml | 23 +-- .rubocop_todo.yml | 226 ++++++++++----------- .../components/markdown/suggestion_diff_row.vue | 7 +- app/assets/stylesheets/utilities.scss | 2 +- app/models/user.rb | 8 +- .../admin/application_settings/_usage.html.haml | 4 +- .../clusters/clusters/_advanced_settings.html.haml | 28 ++- .../instance_statistics/cohorts/index.html.haml | 2 +- app/views/shared/_ping_consent.html.haml | 2 +- .../unreleased/jprovazn-fix-group-preloader.yml | 5 + .../unreleased/tidy-cluster-advanced-settings.yml | 5 + .../unreleased/unauthaccess-to-public-keys.yml | 5 + doc/api/users.md | 8 +- doc/development/testing_guide/end_to_end/index.md | 34 +++- lib/api/users.rb | 8 +- locale/gitlab.pot | 21 ++ .../monitoring/components/dashboard_spec.js | 3 - .../markdown/suggestion_diff_row_spec.js | 46 ++++- spec/requests/api/users_spec.rb | 21 ++ ...ternal_authorization_service_shared_examples.rb | 4 +- .../paginated_collection_shared_examples.rb | 2 +- .../repository_lfs_file_load_examples.rb | 14 +- .../controllers/todos_shared_examples.rb | 8 +- .../controllers/uploads_actions_shared_examples.rb | 28 +-- .../discussions_provider_shared_examples.rb | 2 +- .../api/custom_attributes_shared_examples.rb | 26 +-- .../requests/api/diff_discussions.rb | 12 +- .../shared_examples/requests/api/discussions.rb | 50 ++--- .../requests/api/issuable_participants_examples.rb | 6 +- spec/support/shared_examples/requests/api/notes.rb | 44 ++-- .../requests/api/resolvable_discussions.rb | 20 +- .../requests/api/status_shared_examples.rb | 8 +- .../requests/rack_attack_shared_examples.rb | 32 +-- .../shared_examples/resource_label_events_api.rb | 14 +- .../unique_ip_check_shared_examples.rb | 2 +- 36 files changed, 417 insertions(+), 324 deletions(-) create mode 100644 changelogs/unreleased/jprovazn-fix-group-preloader.yml create mode 100644 changelogs/unreleased/tidy-cluster-advanced-settings.yml create mode 100644 changelogs/unreleased/unauthaccess-to-public-keys.yml diff --git a/.gitlab/issue_templates/Feature proposal.md b/.gitlab/issue_templates/Feature proposal.md index 45e9c58205f..ea37cad6f15 100644 --- a/.gitlab/issue_templates/Feature proposal.md +++ b/.gitlab/issue_templates/Feature proposal.md @@ -36,9 +36,16 @@ Personas are described at https://about.gitlab.com/handbook/marketing/product-ma Add all known Documentation Requirements here, per https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html#documentation-requirements If this feature requires changing permissions, this document https://docs.gitlab.com/ee/user/permissions.html must be updated accordingly. --> -### Testing +### Availability & Testing - + ### What does success look like, and how can we measure that? diff --git a/.rubocop.yml b/.rubocop.yml index da14413deb7..b374012cac5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -301,24 +301,6 @@ RSpec/AnyInstanceOf: Enabled: false # Cops for upgrade to gitlab-styles 3.1.0 -Rails/SafeNavigationWithBlank: - Enabled: false - -Rails/ApplicationController: - Enabled: false - -Rails/ApplicationMailer: - Enabled: false - -Rails/RakeEnvironment: - Enabled: false - -Rails/HelperInstanceVariable: - Enabled: false - -Rails/EnumHash: - Enabled: false - RSpec/ReceiveCounts: Enabled: false @@ -362,10 +344,13 @@ RSpec/UnspecifiedException: Enabled: false RSpec/HaveGitlabHttpStatus: - Enabled: false + Enabled: true + Include: + - 'spec/support/shared_examples/**/*' Style/MultilineWhenThen: Enabled: false Style/FloatDivision: Enabled: false + \ No newline at end of file diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2a3f16683cf..6d1c25836b0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,25 +1,26 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2019-05-04 16:01:00 +0000 using RuboCop version 0.68.1. +# on 2020-01-16 11:53:06 -0800 using RuboCop version 0.74.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 264 +# Offense count: 299 +# Cop supports --auto-correct. Capybara/CurrentPathExpectation: Enabled: false -# Offense count: 1097 +# Offense count: 1432 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: with_first_argument, with_fixed_indentation Layout/AlignArguments: Enabled: false -# Offense count: 824 +# Offense count: 1630 # Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. # SupportedHashRocketStyles: key, separator, table # SupportedColonStyles: key, separator, table # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit @@ -32,39 +33,32 @@ Layout/ClosingHeredocIndentation: Exclude: - 'app/graphql/mutations/merge_requests/set_wip.rb' - 'ee/db/geo/migrate/20180322062741_migrate_ci_job_artifacts_to_separate_registry.rb' - - 'ee/db/migrate/20160204190809_update_jenkins_service_category.rb' - - 'ee/lib/gitlab/background_migration/prune_orphaned_geo_events.rb' - 'ee/lib/gitlab/geo/health_check.rb' - 'lib/gitlab/background_migration/populate_untracked_uploads.rb' - - 'qa/qa/service/kubernetes_cluster.rb' - 'spec/features/merge_request/user_sees_diff_spec.rb' - 'spec/lib/gitlab/asciidoc_spec.rb' - 'spec/lib/gitlab/checks/project_moved_spec.rb' - 'spec/rubocop/cop/active_record_association_reload_spec.rb' - 'spec/services/task_list_toggle_service_spec.rb' -# Offense count: 14 +# Offense count: 9 # Cop supports --auto-correct. Layout/ClosingParenthesisIndentation: Exclude: - 'db/post_migrate/20180704145007_update_project_indexes.rb' - 'ee/db/geo/migrate/20180405074130_add_partial_index_project_repository_verification.rb' - - 'ee/db/migrate/20180308234102_add_partial_index_to_project_repository_states_checksum_columns.rb' - - 'ee/db/post_migrate/20180605213516_fix_partial_index_to_project_repository_states_checksum_columns.rb' - - 'ee/lib/ee/gitlab/usage_data.rb' - 'spec/services/issues/resolve_discussions_spec.rb' - 'spec/services/projects/update_service_spec.rb' - 'spec/support/helpers/stub_object_storage.rb' - 'spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: leading, trailing Layout/DotPosition: Exclude: - 'app/models/concerns/relative_positioning.rb' - - 'app/models/group.rb' # Offense count: 69 # Cop supports --auto-correct. @@ -81,74 +75,67 @@ Layout/EmptyLinesAroundArguments: - 'lib/banzai/pipeline/single_line_pipeline.rb' - 'spec/features/markdown/copy_as_gfm_spec.rb' -# Offense count: 160 +# Offense count: 305 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets Layout/IndentFirstArrayElement: Enabled: false -# Offense count: 631 +# Offense count: 1005 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces Layout/IndentFirstHashElement: Enabled: false -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: consistent, align_parentheses Layout/IndentFirstParameter: Exclude: - - 'app/models/ci/pipeline_schedule.rb' - 'lib/gitlab/cross_project_access.rb' - 'lib/gitlab/data_builder/push.rb' - 'spec/support/helpers/repo_helpers.rb' - 'spec/support/helpers/stub_object_storage.rb' -# Offense count: 5 +# Offense count: 1 # Cop supports --auto-correct. Layout/LeadingBlankLines: Exclude: - - 'app/workers/update_project_statistics_worker.rb' - - 'db/migrate/20161007073613_create_user_activities.rb' - - 'ee/spec/helpers/boards_helper_spec.rb' - 'lib/tasks/yarn.rake' - - 'spec/javascripts/fixtures/merge_requests_diffs.rb' -# Offense count: 30 +# Offense count: 54 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/MultilineOperationIndentation: Enabled: false -# Offense count: 13 +# Offense count: 10 # Cop supports --auto-correct. Layout/RescueEnsureAlignment: Exclude: - 'app/models/blob_viewer/dependency_manager.rb' - - 'app/models/ci/pipeline.rb' - 'app/models/project.rb' - 'app/services/prometheus/proxy_service.rb' - 'app/workers/delete_stored_files_worker.rb' - 'app/workers/reactive_caching_worker.rb' - 'config/initializers/1_settings.rb' - 'config/initializers/trusted_proxies.rb' - - 'ee/db/migrate/20151113115819_canonicalize_kerberos_identities.rb' - 'lib/gitlab/background_migration/archive_legacy_traces.rb' - 'lib/gitlab/highlight.rb' - 'lib/tasks/gitlab/lfs/migrate.rake' -# Offense count: 344 +# Offense count: 522 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: require_no_space, require_space Layout/SpaceInLambdaLiteral: Enabled: false -# Offense count: 583 +# Offense count: 796 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -156,7 +143,7 @@ Layout/SpaceInLambdaLiteral: Layout/SpaceInsideBlockBraces: Enabled: false -# Offense count: 255 +# Offense count: 315 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -185,13 +172,13 @@ Lint/DuplicateMethods: - 'lib/gitlab/git/tree.rb' - 'lib/gitlab/git/wiki_page.rb' -# Offense count: 2 +# Offense count: 3 Lint/InterpolationCheck: Exclude: - 'spec/features/issues/filtered_search/filter_issues_spec.rb' - 'spec/services/quick_actions/interpret_service_spec.rb' -# Offense count: 326 +# Offense count: 122 # Configuration parameters: MaximumRangeSize. Lint/MissingCopEnableDirective: Enabled: false @@ -211,14 +198,13 @@ Lint/ToJSON: - 'lib/gitlab/cycle_analytics/usage_data.rb' - 'lib/gitlab/template/base_template.rb' -# Offense count: 7 +# Offense count: 6 Lint/UriEscapeUnescape: Exclude: - 'app/controllers/application_controller.rb' - 'app/models/project_services/drone_ci_service.rb' - 'spec/lib/google_api/auth_spec.rb' - 'spec/requests/api/files_spec.rb' - - 'spec/requests/api/internal/base_spec.rb' # Offense count: 1 # Configuration parameters: CheckForMethodsWithNoSideEffects. @@ -226,14 +212,14 @@ Lint/Void: Exclude: - 'lib/gitlab/git/diff_collection.rb' -# Offense count: 158 +# Offense count: 165 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: Max: 176 -# Offense count: 94 +# Offense count: 143 # Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: @@ -250,32 +236,32 @@ Naming/HeredocDelimiterCase: - 'spec/support/helpers/repo_helpers.rb' - 'spec/support/helpers/seed_repo.rb' -# Offense count: 197 +# Offense count: 211 # Configuration parameters: Blacklist. # Blacklist: (?-mix:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Enabled: false -# Offense count: 125 +# Offense count: 139 # Cop supports --auto-correct. # Configuration parameters: PreferredName. Naming/RescuedExceptionsVariableName: Enabled: false -# Offense count: 7081 +# Offense count: 9913 # Configuration parameters: Prefixes. # Prefixes: when, with, without RSpec/ContextWording: Enabled: false -# Offense count: 719 +# Offense count: 879 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: method_call, block RSpec/ExpectChange: Enabled: false -# Offense count: 512 +# Offense count: 660 RSpec/ExpectInHook: Enabled: false @@ -317,40 +303,38 @@ RSpec/MultipleSubjects: Exclude: - 'spec/services/merge_requests/create_from_issue_service_spec.rb' -# Offense count: 4 +# Offense count: 3 RSpec/OverwritingSetup: Exclude: - - 'spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb' - 'spec/models/email_spec.rb' - 'spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb' - 'spec/services/notes/quick_actions_service_spec.rb' -# Offense count: 1828 +# Offense count: 2018 # Cop supports --auto-correct. -# Configuration parameters: Strict, EnforcedStyle. +# Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers. # SupportedStyles: inflected, explicit RSpec/PredicateMatcher: Enabled: false -# Offense count: 57 +# Offense count: 69 RSpec/RepeatedExample: Enabled: false -# Offense count: 474 +# Offense count: 584 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: and_return, block RSpec/ReturnFromStub: Enabled: false -# Offense count: 188 +# Offense count: 380 RSpec/ScatteredLet: Enabled: false -# Offense count: 10 +# Offense count: 8 RSpec/ScatteredSetup: Exclude: - - 'spec/controllers/projects/templates_controller_spec.rb' - 'spec/lib/gitlab/bitbucket_import/importer_spec.rb' - 'spec/requests/api/jobs_spec.rb' - 'spec/services/projects/create_service_spec.rb' @@ -369,6 +353,27 @@ RSpec/VoidExpect: - 'spec/models/ci/runner_spec.rb' - 'spec/services/users/destroy_service_spec.rb' +# Offense count: 10 +# Cop supports --auto-correct. +Rails/ApplicationController: + Exclude: + - 'app/controllers/acme_challenges_controller.rb' + - 'app/controllers/chaos_controller.rb' + - 'app/controllers/health_controller.rb' + - 'app/controllers/metrics_controller.rb' + - 'ee/app/controllers/oauth/geo_auth_controller.rb' + - 'ee/spec/helpers/ee/services_helper_spec.rb' + - 'lib/gitlab/base_doorkeeper_controller.rb' + - 'lib/gitlab/request_forgery_protection.rb' + - 'spec/controllers/concerns/continue_params_spec.rb' + - 'spec/lib/marginalia_spec.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Rails/ApplicationMailer: + Exclude: + - 'app/mailers/base_mailer.rb' + # Offense count: 8 # Cop supports --auto-correct. Rails/BelongsTo: @@ -378,39 +383,37 @@ Rails/BelongsTo: - 'ee/app/models/prometheus_alert.rb' - 'ee/app/models/prometheus_alert_event.rb' -# Offense count: 80 +# Offense count: 151 # Configuration parameters: Include. # Include: db/migrate/*.rb Rails/CreateTableWithTimestamps: Enabled: false -# Offense count: 222 +# Offense count: 266 # Configuration parameters: EnforcedStyle. # SupportedStyles: slashes, arguments Rails/FilePath: Enabled: false -# Offense count: 167 +# Offense count: 211 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/HasManyOrHasOneDependent: Enabled: false -# Offense count: 2 +# Offense count: 431 # Configuration parameters: Include. -# Include: app/controllers/**/*.rb -Rails/IgnoredSkipActionFilterOption: - Exclude: - - 'app/controllers/projects/snippets_controller.rb' - - 'app/controllers/snippets_controller.rb' +# Include: app/helpers/**/*.rb +Rails/HelperInstanceVariable: + Enabled: false -# Offense count: 87 +# Offense count: 103 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/InverseOf: Enabled: false -# Offense count: 46 +# Offense count: 51 # Configuration parameters: Include. # Include: app/controllers/**/*.rb Rails/LexicallyScopedActionFilter: @@ -425,6 +428,12 @@ Rails/LinkToBlank: - 'ee/app/helpers/ee/user_callouts_helper.rb' - 'ee/app/helpers/license_helper.rb' +# Offense count: 35 +# Configuration parameters: Include. +# Include: **/Rakefile, **/*.rake +Rails/RakeEnvironment: + Enabled: false + # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: Include. @@ -433,31 +442,16 @@ Rails/RedundantAllowNil: Exclude: - 'app/models/application_setting.rb' -# Offense count: 2 -# Configuration parameters: Include. -# Include: db/migrate/*.rb -Rails/ReversibleMigration: - Exclude: - - 'db/migrate/20160824103857_drop_unused_ci_tables.rb' - -# Offense count: 860 +# Offense count: 868 # Configuration parameters: Blacklist, Whitelist. # Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters Rails/SkipsModelValidations: Enabled: false -# Offense count: 1 -# Configuration parameters: Environments. -# Environments: development, test, production -Rails/UnknownEnv: - Exclude: - - 'db/migrate/20171124125748_populate_missing_merge_request_statuses.rb' - -# Offense count: 11 +# Offense count: 8 # Cop supports --auto-correct. Security/YAMLLoad: Exclude: - - 'lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb' - 'lib/gitlab/redis/wrapper.rb' - 'lib/system_check/incoming_email/imap_authentication_check.rb' - 'spec/config/mail_room_spec.rb' @@ -470,7 +464,7 @@ Security/YAMLLoad: Style/AccessModifierDeclarations: Enabled: false -# Offense count: 121 +# Offense count: 127 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: percent_q, bare_percent @@ -489,19 +483,18 @@ Style/Dir: Exclude: - 'qa/qa.rb' -# Offense count: 7 +# Offense count: 6 # Cop supports --auto-correct. Style/EachWithObject: Exclude: - 'lib/expand_variables.rb' - 'lib/gitlab/ci/ansi2html.rb' - - 'lib/gitlab/ee_compat_check.rb' - 'lib/gitlab/hook_data/issuable_builder.rb' - 'lib/gitlab/i18n/po_linter.rb' - 'lib/gitlab/import_export/members_mapper.rb' - 'lib/gitlab/import_export/relation_factory.rb' -# Offense count: 34 +# Offense count: 41 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty, nil, both @@ -515,7 +508,7 @@ Style/EmptyLambdaParameter: - 'app/models/ci/build.rb' - 'app/models/ci/runner.rb' -# Offense count: 9 +# Offense count: 8 # Cop supports --auto-correct. Style/EmptyLiteral: Exclude: @@ -523,40 +516,40 @@ Style/EmptyLiteral: - 'lib/gitlab/git/diff_collection.rb' - 'lib/gitlab/gitaly_client.rb' - 'spec/helpers/merge_requests_helper_spec.rb' - - 'spec/lib/gitlab/request_context_spec.rb' - 'spec/lib/gitlab/workhorse_spec.rb' - 'spec/requests/api/jobs_spec.rb' - 'spec/support/shared_examples/chat_slash_commands_shared_examples.rb' -# Offense count: 180 +# Offense count: 148 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, expanded Style/EmptyMethod: Enabled: false -# Offense count: 203 +# Offense count: 346 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent Style/FormatString: Enabled: false -# Offense count: 669 +# Offense count: 692 # Configuration parameters: MinBodyLength. Style/GuardClause: Enabled: false # Offense count: 27 +# Configuration parameters: AllowIfModifier. Style/IfInsideElse: Enabled: false -# Offense count: 1346 +# Offense count: 1474 # Cop supports --auto-correct. Style/IfUnlessModifier: Enabled: false -# Offense count: 186 +# Offense count: 314 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: line_count_dependent, lambda, literal @@ -570,11 +563,11 @@ Style/LineEndConcatenation: - 'spec/lib/gitlab/gfm/reference_rewriter_spec.rb' - 'spec/lib/gitlab/incoming_email_spec.rb' -# Offense count: 18 +# Offense count: 17 Style/MethodMissingSuper: Enabled: false -# Offense count: 18 +# Offense count: 17 Style/MissingRespondToMissing: Enabled: false @@ -597,35 +590,28 @@ Style/MultilineIfModifier: - 'app/services/ci/process_pipeline_service.rb' - 'lib/api/commit_statuses.rb' -# Offense count: 72 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: literals, strict -Style/MutableConstant: - Enabled: false - -# Offense count: 28 +# Offense count: 34 # Cop supports --auto-correct. # Configuration parameters: Whitelist. # Whitelist: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with Style/NestedParenthesizedCalls: Enabled: false -# Offense count: 31 +# Offense count: 25 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinBodyLength. # SupportedStyles: skip_modifier_ifs, always Style/Next: Enabled: false -# Offense count: 67 +# Offense count: 71 # Cop supports --auto-correct. # Configuration parameters: EnforcedOctalStyle. # SupportedOctalStyles: zero_with_o, zero_only Style/NumericLiteralPrefix: Enabled: false -# Offense count: 186 +# Offense count: 234 # Cop supports --auto-correct. # Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison @@ -639,12 +625,12 @@ Style/OrAssignment: - 'lib/api/commit_statuses.rb' - 'lib/gitlab/project_transfer.rb' -# Offense count: 79 +# Offense count: 106 # Cop supports --auto-correct. Style/ParallelAssignment: Enabled: false -# Offense count: 1390 +# Offense count: 1692 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. Style/PercentLiteralDelimiters: @@ -666,7 +652,7 @@ Style/PerlBackrefs: - 'lib/gitlab/search_results.rb' - 'lib/gitlab/sherlock/query.rb' -# Offense count: 129 +# Offense count: 165 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: compact, exploded @@ -687,7 +673,7 @@ Style/RedundantConditional: Exclude: - 'lib/system_check/helpers.rb' -# Offense count: 360 +# Offense count: 221 # Cop supports --auto-correct. Style/RedundantFreeze: Enabled: false @@ -707,31 +693,31 @@ Style/RedundantReturn: - 'lib/gitlab/utils.rb' - 'lib/google_api/auth.rb' -# Offense count: 700 +# Offense count: 739 # Cop supports --auto-correct. Style/RedundantSelf: Enabled: false -# Offense count: 28 +# Offense count: 80 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: Enabled: false -# Offense count: 41 +# Offense count: 42 # Cop supports --auto-correct. Style/RescueModifier: Enabled: false -# Offense count: 197 +# Offense count: 237 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit Style/RescueStandardError: Enabled: false -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. Style/SelfAssignment: Exclude: @@ -746,7 +732,7 @@ Style/SingleLineMethods: Exclude: - 'lib/gitlab/ci/ansi2html.rb' -# Offense count: 91 +# Offense count: 94 # Cop supports --auto-correct. # Configuration parameters: . # SupportedStyles: use_perl_names, use_english_names @@ -759,14 +745,14 @@ Style/StderrPuts: Exclude: - 'config/initializers/rspec_profiling.rb' -# Offense count: 65 +# Offense count: 75 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: single_quotes, double_quotes Style/StringLiteralsInInterpolation: Enabled: false -# Offense count: 187 +# Offense count: 216 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. # IgnoredMethods: respond_to, define_method @@ -793,24 +779,22 @@ Style/TrailingCommaInArguments: Exclude: - 'spec/features/markdown/copy_as_gfm_spec.rb' -# Offense count: 10 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInArrayLiteral: Exclude: - 'ee/spec/models/project_spec.rb' - - 'spec/lib/gitlab/diff/position_tracer_spec.rb' - 'spec/lib/gitlab/metrics/dashboard/processor_spec.rb' -# Offense count: 2 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInHashLiteral: Exclude: - 'lib/gitlab/ci/ansi2html.rb' - - 'lib/gitlab/kubernetes.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -819,7 +803,7 @@ Style/UnlessElse: - 'lib/backup/manager.rb' - 'lib/gitlab/project_search_results.rb' -# Offense count: 10 +# Offense count: 8 # Cop supports --auto-correct. Style/UnneededCondition: Exclude: @@ -827,12 +811,10 @@ Style/UnneededCondition: - 'app/helpers/environment_helper.rb' - 'app/models/project.rb' - 'app/services/issuable/clone/base_service.rb' - - 'app/services/prometheus/adapter_service.rb' - 'lib/gitlab/email/message/repository_push.rb' - - 'lib/gitlab/prometheus_client.rb' - 'spec/lib/rspec_flaky/flaky_example_spec.rb' -# Offense count: 73 +# Offense count: 99 # Cop supports --auto-correct. Style/UnneededInterpolation: Enabled: false diff --git a/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_row.vue b/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_row.vue index 97d93eaaf3f..112bd03b49b 100644 --- a/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_row.vue +++ b/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff_row.vue @@ -8,6 +8,9 @@ export default { }, }, computed: { + displayAsCell() { + return !(this.line.rich_text || this.line.text); + }, lineType() { return this.line.type; }, @@ -23,11 +26,9 @@ export default { {{ line.new_line }} - + {{ line.text }} - - diff --git a/app/assets/stylesheets/utilities.scss b/app/assets/stylesheets/utilities.scss index 1517015dda0..1358b3aa6dd 100644 --- a/app/assets/stylesheets/utilities.scss +++ b/app/assets/stylesheets/utilities.scss @@ -41,6 +41,7 @@ .mh-50vh { max-height: 50vh; } .gl-w-64 { width: px-to-rem($grid-size * 8); } +.gl-h-32 { height: px-to-rem($grid-size * 4); } .gl-h-64 { height: px-to-rem($grid-size * 8); } .gl-text-purple { color: $purple; } @@ -59,4 +60,3 @@ .gl-text-red-700 { @include gl-text-red-700; } .gl-text-orange-700 { @include gl-text-orange-700; } .gl-text-green-700 { @include gl-text-green-700; } - diff --git a/app/models/user.rb b/app/models/user.rb index df54f358ffa..be9f528e1bd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -223,19 +223,19 @@ class User < ApplicationRecord after_initialize :set_projects_limit # User's Layout preference - enum layout: [:fixed, :fluid] + enum layout: { fixed: 0, fluid: 1 } # User's Dashboard preference # Note: When adding an option, it MUST go on the end of the array. - enum dashboard: [:projects, :stars, :project_activity, :starred_project_activity, :groups, :todos, :issues, :merge_requests, :operations] + enum dashboard: { projects: 0, stars: 1, project_activity: 2, starred_project_activity: 3, groups: 4, todos: 5, issues: 6, merge_requests: 7, operations: 8 } # User's Project preference # Note: When adding an option, it MUST go on the end of the array. - enum project_view: [:readme, :activity, :files] + enum project_view: { readme: 0, activity: 1, files: 2 } # User's role # Note: When adding an option, it MUST go on the end of the array. - enum role: [:software_developer, :development_team_lead, :devops_engineer, :systems_administrator, :security_analyst, :data_analyst, :product_manager, :product_designer, :other], _suffix: true + enum role: { software_developer: 0, development_team_lead: 1, devops_engineer: 2, systems_administrator: 3, security_analyst: 4, data_analyst: 5, product_manager: 6, product_designer: 7, other: 8 }, _suffix: true delegate :path, to: :namespace, allow_nil: true, prefix: true delegate :notes_filter_for, to: :user_preference diff --git a/app/views/admin/application_settings/_usage.html.haml b/app/views/admin/application_settings/_usage.html.haml index d716b52be05..b4fe1bbf028 100644 --- a/app/views/admin/application_settings/_usage.html.haml +++ b/app/views/admin/application_settings/_usage.html.haml @@ -9,7 +9,7 @@ Enable version check .form-text.text-muted GitLab will inform you if a new version is available. - = link_to 'Learn more', help_page_path("user/admin_area/settings/usage_statistics", anchor: "version-check") + = link_to 'Learn more', help_page_path('user/admin_area/settings/usage_statistics', anchor: 'version-check-core-only') about what information is shared with GitLab Inc. .form-group - can_be_configured = @application_setting.usage_ping_can_be_configured? @@ -21,7 +21,7 @@ - if can_be_configured %p.mb-2= _('To help improve GitLab and its user experience, GitLab will periodically collect usage information.') - - usage_ping_path = help_page_path('user/admin_area/settings/usage_statistics', anchor: 'usage-ping') + - usage_ping_path = help_page_path('user/admin_area/settings/usage_statistics', anchor: 'usage-ping-core-only') - usage_ping_link_start = ''.html_safe % { url: usage_ping_path } %p.mb-2= s_('%{usage_ping_link_start}Learn more%{usage_ping_link_end} about what information is shared with GitLab Inc.').html_safe % { usage_ping_link_start: usage_ping_link_start, usage_ping_link_end: ''.html_safe } diff --git a/app/views/clusters/clusters/_advanced_settings.html.haml b/app/views/clusters/clusters/_advanced_settings.html.haml index 77f7c478ffa..d823cd0412b 100644 --- a/app/views/clusters/clusters/_advanced_settings.html.haml +++ b/app/views/clusters/clusters/_advanced_settings.html.haml @@ -6,27 +6,25 @@ - if can?(current_user, :admin_cluster, @cluster) - unless @cluster.provided_by_user? - .append-bottom-20 - %label.append-bottom-10 + .sub-section.form-group + %h4 = @cluster.provider_label %p - provider_link = link_to(@cluster.provider_label, @cluster.provider_management_url, target: '_blank', rel: 'noopener noreferrer') = s_('ClusterIntegration|Manage your Kubernetes cluster by visiting %{provider_link}').html_safe % { provider_link: provider_link } - = form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster, html: { class: 'cluster_management_form' } do |field| - - %h5 - = s_('ClusterIntegration|Cluster management project (alpha)') + .sub-section.form-group + = form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster, html: { class: 'cluster_management_form' } do |field| + %h4 + = s_('ClusterIntegration|Cluster management project (alpha)') - .form-group - .form-text.text-muted - = project_select_tag('cluster[management_project_id]', class: 'hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit', - placeholder: _('Select project'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', simple_filter: true, allow_clear: true, include_groups: false, include_projects_in_subgroups: true, group_id: group_id, user_id: user_id }, value: @cluster.management_project_id) - .text-muted - = s_('ClusterIntegration|A cluster management project can be used to run deployment jobs with Kubernetes cluster-admin privileges.').html_safe - = link_to _('More information'), help_page_path('user/clusters/management_project.md'), target: '_blank' - .form-group - = field.submit _('Save changes'), class: 'btn btn-success qa-save-domain' + %p + = project_select_tag('cluster[management_project_id]', class: 'hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit', + placeholder: _('Select project'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', simple_filter: true, allow_clear: true, include_groups: false, include_projects_in_subgroups: true, group_id: group_id, user_id: user_id }, value: @cluster.management_project_id) + .text-muted + = s_('ClusterIntegration|A cluster management project can be used to run deployment jobs with Kubernetes cluster-admin privileges.').html_safe + = link_to _('More information'), help_page_path('user/clusters/management_project.md'), target: '_blank' + = field.submit _('Save changes'), class: 'btn btn-success' - if @cluster.managed? .sub-section.form-group diff --git a/app/views/instance_statistics/cohorts/index.html.haml b/app/views/instance_statistics/cohorts/index.html.haml index c438566cb05..5333f8b7a1f 100644 --- a/app/views/instance_statistics/cohorts/index.html.haml +++ b/app/views/instance_statistics/cohorts/index.html.haml @@ -9,6 +9,6 @@ - usage_ping_link_start = ''.html_safe % { url: usage_ping_path } = s_('User Cohorts are only shown when the %{usage_ping_link_start}usage ping%{usage_ping_link_end} is enabled.').html_safe % { usage_ping_link_start: usage_ping_link_start, usage_ping_link_end: ''.html_safe } - if current_user.admin? - - application_settings_path = admin_application_settings_path(anchor: 'usage-statistics') + - application_settings_path = metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings') - application_settings_link_start = ''.html_safe % { url: application_settings_path } = s_('To enable it and see User Cohorts, visit %{application_settings_link_start}application settings%{application_settings_link_end}.').html_safe % { application_settings_link_start: application_settings_link_start, application_settings_link_end: ''.html_safe } diff --git a/app/views/shared/_ping_consent.html.haml b/app/views/shared/_ping_consent.html.haml index f8eb2b2833b..ded9b55056a 100644 --- a/app/views/shared/_ping_consent.html.haml +++ b/app/views/shared/_ping_consent.html.haml @@ -1,6 +1,6 @@ - if session[:ask_for_usage_stats_consent] .ping-consent-message.alert.alert-warning.flex-alert - - settings_link_start = ''.html_safe % { url: admin_application_settings_path(anchor: 'js-usage-settings') } + - settings_link_start = ''.html_safe % { url: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings') } - info_link_start = ''.html_safe % { url: help_page_path('user/admin_area/settings/usage_statistics.md') } .alert-message = s_('To help improve GitLab, we would like to periodically collect usage information. This can be changed at any time in %{settings_link_start}Settings%{link_end}. %{info_link_start}More Information%{link_end}').html_safe % { settings_link_start: settings_link_start, info_link_start: info_link_start, link_end: ''.html_safe } diff --git a/changelogs/unreleased/jprovazn-fix-group-preloader.yml b/changelogs/unreleased/jprovazn-fix-group-preloader.yml new file mode 100644 index 00000000000..b2211fb81af --- /dev/null +++ b/changelogs/unreleased/jprovazn-fix-group-preloader.yml @@ -0,0 +1,5 @@ +--- +title: Fix loading of sub-epics caused by wrong subscription check. +merge_request: 23184 +author: +type: fixed diff --git a/changelogs/unreleased/tidy-cluster-advanced-settings.yml b/changelogs/unreleased/tidy-cluster-advanced-settings.yml new file mode 100644 index 00000000000..64683fd892d --- /dev/null +++ b/changelogs/unreleased/tidy-cluster-advanced-settings.yml @@ -0,0 +1,5 @@ +--- +title: Use consistent layout in cluster advanced settings +merge_request: 22656 +author: +type: other diff --git a/changelogs/unreleased/unauthaccess-to-public-keys.yml b/changelogs/unreleased/unauthaccess-to-public-keys.yml new file mode 100644 index 00000000000..c10d468489b --- /dev/null +++ b/changelogs/unreleased/unauthaccess-to-public-keys.yml @@ -0,0 +1,5 @@ +--- +title: Allow SSH keys API endpoint to be requested for a given username +merge_request: 22899 +author: Rajendra Kadam +type: changed diff --git a/doc/api/users.md b/doc/api/users.md index 4491a339d25..4ba524d6d1d 100644 --- a/doc/api/users.md +++ b/doc/api/users.md @@ -677,12 +677,12 @@ Parameters: Get a list of a specified user's SSH keys. ``` -GET /users/:id/keys +GET /users/:id_or_username/keys ``` -Parameters: - -- `id` (required) - id of specified user +| Attribute | Type | Required | Description | +| ---------------- | ------ | -------- | ----------- | +| `id_or_username` | string | yes | The id or username of the user to get the SSH keys for. | ## Single SSH key diff --git a/doc/development/testing_guide/end_to_end/index.md b/doc/development/testing_guide/end_to_end/index.md index 96141a5d68d..7e325bd5f42 100644 --- a/doc/development/testing_guide/end_to_end/index.md +++ b/doc/development/testing_guide/end_to_end/index.md @@ -85,6 +85,35 @@ subgraph "gitlab-qa pipeline" 1. The result of the GitLab QA pipeline is being propagated upstream, through Omnibus, back to the CE / EE merge request. +Please note, we plan to [add more specific information](https://gitlab.com/gitlab-org/quality/team-tasks/issues/156) +about the tests included in each job/scenario that runs in `gitlab-qa`. + +##### Running custom tests + +The [existing scenarios](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md) +that run in the downstream `gitlab-qa` pipeline include many tests, but there are times when you might want to run a +test or a group of tests that are different than the groups in any of the existing scenarios. + +For example, when we [dequarantine](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#dequarantining-tests) +a flaky test we first want to make sure that it's no longer flaky. +We can do that using the `ce:custom-parallel` and `ee:custom-parallel` jobs. +Both are manual jobs that you can configure using custom variables. +When you click the name (not the play icon) of one of the parallel jobs, +you'll be prompted to enter variables. You can use any of [the variables +that can be used with `gitlab-qa`](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#supported-gitlab-environment-variables) +as well as these: + +| Variable | Description | +|-|-| +| `QA_SCENARIO` | The scenario to run (default `Test::Instance::Image`) | +| `QA_TESTS` | The test(s) to run (no default, which means run all the tests in the scenario). Use file paths as you would when running tests via RSpec, e.g., `qa/specs/features/ee/browser_ui` would include all the `EE` UI tests. | +| `QA_RSPEC_TAGS` | The RSpec tags to add (no default) | + +For now [manual jobs with custom variables will not use the same variable +when retried](https://gitlab.com/gitlab-org/gitlab/issues/31367), so if you want to run the same test(s) multiple times, +specify the same variables in each `custom-parallel` job (up to as +many of the 10 available jobs that you want to run). + #### Using the `review-qa-all` jobs On every pipeline during the `test` stage, the `review-qa-smoke` job is @@ -105,8 +134,9 @@ See [Review Apps][review-apps] for more details about Review Apps. ## How do I run the tests? -There are two main options for running the tests. If you simply want to run the -existing tests against a live GitLab instance or against a pre-built docker image +If you are not [testing code in a merge request](#testing-code-in-merge-requests), +there are two main options for running the tests. If you simply want to run +the existing tests against a live GitLab instance or against a pre-built docker image you can use the [GitLab QA orchestrator][gitlab-qa-readme]. See also [examples of the test scenarios you can run via the orchestrator](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#examples). diff --git a/lib/api/users.rb b/lib/api/users.rb index bf1fe4fc4a8..120f66b6a71 100644 --- a/lib/api/users.rb +++ b/lib/api/users.rb @@ -252,17 +252,15 @@ module API success Entities::SSHKey end params do - requires :id, type: Integer, desc: 'The ID of the user' + requires :user_id, type: String, desc: 'The ID or username of the user' use :pagination end - # rubocop: disable CodeReuse/ActiveRecord - get ':id/keys' do - user = User.find_by(id: params[:id]) + get ':user_id/keys', requirements: API::USER_REQUIREMENTS do + user = find_user(params[:user_id]) 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 success Entities::SSHKey diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 04ce92d64ec..3a784cd552e 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -638,6 +638,12 @@ msgstr "" msgid "1st contribution!" msgstr "" +msgid "2 days" +msgstr "" + +msgid "2 weeks" +msgstr "" + msgid "20-29 contributions" msgstr "" @@ -665,6 +671,9 @@ msgstr "" msgid "30+ contributions" msgstr "" +msgid "4 hours" +msgstr "" + msgid "403|Please contact your GitLab administrator to get permission." msgstr "" @@ -7183,6 +7192,9 @@ msgstr "" msgid "Environments|Show all" msgstr "" +msgid "Environments|Show last" +msgstr "" + msgid "Environments|Stop" msgstr "" @@ -13082,6 +13094,9 @@ msgstr "" msgid "Past due" msgstr "" +msgid "Past week" +msgstr "" + msgid "Paste a machine public key here. Read more about how to generate it %{link_start}here%{link_end}" msgstr "" @@ -21776,6 +21791,9 @@ msgstr "" msgid "ciReport|%{linkStartTag}Learn more about SAST %{linkEndTag}" msgstr "" +msgid "ciReport|%{linkStartTag}Learn more about codequality reports %{linkEndTag}" +msgstr "" + msgid "ciReport|%{namespace} is affected by %{vulnerability}." msgstr "" @@ -21864,6 +21882,9 @@ msgstr "" msgid "ciReport|Automatically apply the patch in a new branch" msgstr "" +msgid "ciReport|Base pipeline codequality artifact not found" +msgstr "" + msgid "ciReport|Class" msgstr "" diff --git a/spec/frontend/monitoring/components/dashboard_spec.js b/spec/frontend/monitoring/components/dashboard_spec.js index 85408d57dde..c5cb67b4e6f 100644 --- a/spec/frontend/monitoring/components/dashboard_spec.js +++ b/spec/frontend/monitoring/components/dashboard_spec.js @@ -124,9 +124,6 @@ describe('Dashboard', () => { .then(() => { expect(wrapper.vm.showEmptyState).toEqual(false); expect(wrapper.vm.$el.querySelector('.prometheus-panel')).toEqual(null); - // TODO: The last expectation doesn't belong here, it belongs in a `group_group_spec.js` file - // Issue: https://gitlab.com/gitlab-org/gitlab/issues/118780 - // expect(wrapper.vm.$el.querySelector('.prometheus-graph-group')).toBeTruthy(); done(); }) diff --git a/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js b/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js index 97fcdc67791..6ae405017c9 100644 --- a/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js +++ b/spec/frontend/vue_shared/components/markdown/suggestion_diff_row_spec.js @@ -63,21 +63,59 @@ describe('SuggestionDiffRow', () => { it('renders the plain text when it is available but rich text is not', () => { factory({ propsData: { - line: Object.assign({}, newLine, { rich_text: undefined }), + line: { + ...newLine, + rich_text: undefined, + }, }, }); expect(wrapper.find('td.line_content').text()).toEqual('newplaintext'); }); - it('renders a zero-width space when it has no plain or rich texts', () => { + it('switches to table-cell display when it has no plain or rich texts', () => { factory({ propsData: { - line: Object.assign({}, newLine, { rich_text: undefined, text: undefined }), + line: { + ...newLine, + text: undefined, + rich_text: undefined, + }, }, }); - expect(wrapper.find('td.line_content').text()).toEqual('\u200B'); + const lineContent = wrapper.find('td.line_content'); + + expect(lineContent.classes()).toContain('d-table-cell'); + expect(lineContent.text()).toEqual(''); + }); + + it('does not switch to table-cell display if it has either plain or rich texts', () => { + let lineContent; + + factory({ + propsData: { + line: { + ...newLine, + text: undefined, + }, + }, + }); + + lineContent = wrapper.find('td.line_content'); + expect(lineContent.classes()).not.toContain('d-table-cell'); + + factory({ + propsData: { + line: { + ...newLine, + rich_text: undefined, + }, + }, + }); + + lineContent = wrapper.find('td.line_content'); + expect(lineContent.classes()).not.toContain('d-table-cell'); }); }); diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 0a22a09b8a6..5af56aa6f75 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -913,6 +913,27 @@ describe API::Users do end end + describe 'GET /user/:user_id/keys' do + it 'returns 404 for non-existing user' do + get api("/users/#{not_existing_user_id}/keys") + + expect(response).to have_gitlab_http_status(404) + expect(json_response['message']).to eq('404 User Not Found') + end + + it 'returns array of ssh keys' do + user.keys << key + user.save + + get api("/users/#{user.username}/keys") + + 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) + end + end + describe 'DELETE /user/:id/keys/:key_id' do before do admin diff --git a/spec/support/shared_examples/controllers/external_authorization_service_shared_examples.rb b/spec/support/shared_examples/controllers/external_authorization_service_shared_examples.rb index d8a1ae83f61..cccce7b91b5 100644 --- a/spec/support/shared_examples/controllers/external_authorization_service_shared_examples.rb +++ b/spec/support/shared_examples/controllers/external_authorization_service_shared_examples.rb @@ -16,7 +16,7 @@ shared_examples 'disabled when using an external authorization service' do subject - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -37,6 +37,6 @@ shared_examples 'unauthorized when external service denies access' do subject - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end diff --git a/spec/support/shared_examples/controllers/paginated_collection_shared_examples.rb b/spec/support/shared_examples/controllers/paginated_collection_shared_examples.rb index bd84bd1093f..41a8d2d8117 100644 --- a/spec/support/shared_examples/controllers/paginated_collection_shared_examples.rb +++ b/spec/support/shared_examples/controllers/paginated_collection_shared_examples.rb @@ -11,7 +11,7 @@ shared_examples 'paginated collection' do it 'renders a page number that is not ouf of range' do get action, params: params.merge(page: last_page) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'redirects to last_page if page number is larger than number of pages' do 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 5dea17069f9..8e5fae5da18 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 @@ -51,7 +51,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end context 'and lfs uses object storage' do @@ -65,7 +65,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| it 'responds with redirect to file' do subject - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) expect(response.location).to include(lfs_object.reload.file.path) end @@ -84,7 +84,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| it 'does not serve the file' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -97,7 +97,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| it 'does not serve the file if no members are linked to the LfsObject' do subject - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'serves the file when the fork network root is linked to the LfsObject' do @@ -105,7 +105,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'serves the file when the fork network member is linked to the LfsObject' do @@ -113,7 +113,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -154,7 +154,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| subject - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') expect(response.header['Content-Disposition']) .to eq('inline') diff --git a/spec/support/shared_examples/controllers/todos_shared_examples.rb b/spec/support/shared_examples/controllers/todos_shared_examples.rb index 914bf506320..e220f6bfc9b 100644 --- a/spec/support/shared_examples/controllers/todos_shared_examples.rb +++ b/spec/support/shared_examples/controllers/todos_shared_examples.rb @@ -12,13 +12,13 @@ shared_examples 'todos actions' do post_create end.to change { user.todos.count }.by(1) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'returns todo path and pending count' do post_create - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['count']).to eq 1 expect(json_response['delete_path']).to match(%r{/dashboard/todos/\d{1}}) end @@ -31,7 +31,7 @@ shared_examples 'todos actions' do post_create end.to change { user.todos.count }.by(0) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it 'does not create todo when user is not logged in' do @@ -39,7 +39,7 @@ shared_examples 'todos actions' do post_create end.to change { user.todos.count }.by(0) - expect(response).to have_gitlab_http_status(302) + expect(response).to have_gitlab_http_status(:found) end end 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 8962d98218a..11dd8042b45 100644 --- a/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb +++ b/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb @@ -27,7 +27,7 @@ shared_examples 'handle uploads' do it "returns an error" do post :create, params: params, format: :json - expect(response).to have_gitlab_http_status(422) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end @@ -84,7 +84,7 @@ shared_examples 'handle uploads' do show_upload - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -110,7 +110,7 @@ shared_examples 'handle uploads' do it "responds with status 200" do show_upload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -123,7 +123,7 @@ shared_examples 'handle uploads' do it "responds with status 404" do show_upload - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -135,7 +135,7 @@ shared_examples 'handle uploads' do it "responds with status 404" do show_upload - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -149,7 +149,7 @@ shared_examples 'handle uploads' do it "responds with status 200" do show_upload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -161,7 +161,7 @@ shared_examples 'handle uploads' do it "responds with status 404" do show_upload - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -182,7 +182,7 @@ shared_examples 'handle uploads' do it "responds with status 200" do show_upload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -226,7 +226,7 @@ shared_examples 'handle uploads' do it "responds with status 200" do show_upload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -238,7 +238,7 @@ shared_examples 'handle uploads' do it "responds with status 404" do show_upload - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -253,7 +253,7 @@ shared_examples 'handle uploads' do it "responds with status 200" do show_upload - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -265,7 +265,7 @@ shared_examples 'handle uploads' do it "responds with status 404" do show_upload - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -278,7 +278,7 @@ shared_examples 'handle uploads' do it "responds with status 404" do show_upload - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -321,7 +321,7 @@ shared_examples 'handle uploads authorize' do end it 'responds with status 200' do - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end it 'uses the gitlab-workhorse content type' do diff --git a/spec/support/shared_examples/discussions_provider_shared_examples.rb b/spec/support/shared_examples/discussions_provider_shared_examples.rb index 77cf1ac3f51..0e7f491c6a4 100644 --- a/spec/support/shared_examples/discussions_provider_shared_examples.rb +++ b/spec/support/shared_examples/discussions_provider_shared_examples.rb @@ -6,7 +6,7 @@ shared_examples 'discussions provider' do it 'returns the expected discussions' do get :discussions, params: { namespace_id: project.namespace, project_id: project, id: requested_iid } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('entities/discussions') expect(json_response.size).to eq(expected_discussion_count) 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 776a0bdd29e..22bd6e9cdf7 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 @@ -13,7 +13,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| 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(response).to have_gitlab_http_status(:ok) expect(json_response.size).to be 2 expect(json_response.map { |r| r['id'] }).to contain_exactly attributable.id, other_attributable.id end @@ -23,7 +23,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| 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(response).to have_gitlab_http_status(:ok) expect(json_response.size).to be 1 expect(json_response.first['id']).to eq attributable.id end @@ -39,7 +39,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| 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(response).to have_gitlab_http_status(:ok) expect(json_response.size).to be 2 expect(json_response.first).not_to include 'custom_attributes' end @@ -49,7 +49,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| it 'does not include custom attributes by default' do get api("/#{attributable_name}", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) 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' @@ -58,7 +58,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| 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(response).to have_gitlab_http_status(:ok) expect(json_response.size).to be 2 attributable_response = json_response.find { |r| r['id'] == attributable.id } @@ -79,7 +79,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| 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(response).to have_gitlab_http_status(:ok) expect(json_response).not_to include 'custom_attributes' end end @@ -88,14 +88,14 @@ shared_examples 'custom attributes endpoints' do |attributable_name| 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(response).to have_gitlab_http_status(:ok) 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 } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['custom_attributes']).to contain_exactly( { 'key' => 'foo', 'value' => 'foo' }, { 'key' => 'bar', 'value' => 'bar' } @@ -115,7 +115,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| it 'returns all custom attributes' do get api("/#{attributable_name}/#{attributable.id}/custom_attributes", admin) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to contain_exactly( { 'key' => 'foo', 'value' => 'foo' }, { 'key' => 'bar', 'value' => 'bar' } @@ -135,7 +135,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| 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(response).to have_gitlab_http_status(:ok) expect(json_response).to eq({ 'key' => 'foo', 'value' => 'foo' }) end end @@ -154,7 +154,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| put api("/#{attributable_name}/#{attributable.id}/custom_attributes/new", admin), params: { value: 'new' } end.to change { attributable.custom_attributes.count }.by(1) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq({ 'key' => 'new', 'value' => 'new' }) expect(attributable.custom_attributes.find_by(key: 'new').value).to eq 'new' end @@ -164,7 +164,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin), params: { value: 'new' } end.not_to change { attributable.custom_attributes.count } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to eq({ 'key' => 'foo', 'value' => 'new' }) expect(custom_attribute1.reload.value).to eq 'new' end @@ -184,7 +184,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| delete api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin) end.to change { attributable.custom_attributes.count }.by(-1) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) expect(attributable.custom_attributes.find_by(key: 'foo')).to be_nil 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 a7774d17d3c..8ef3ed3f057 100644 --- a/spec/support/shared_examples/requests/api/diff_discussions.rb +++ b/spec/support/shared_examples/requests/api/diff_discussions.rb @@ -7,7 +7,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| discussion = json_response.find { |record| record['id'] == diff_note.discussion_id } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(discussion).not_to be_nil expect(discussion['individual_note']).to eq(false) expect(discussion['notes'].first['body']).to eq(diff_note.note) @@ -18,7 +18,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| it "returns a discussion by id" do 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(response).to have_gitlab_http_status(:ok) 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) @@ -32,7 +32,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!', position: position } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) 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) @@ -45,7 +45,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!', position: position } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end it "returns a 400 bad request error when the position is not valid for this discussion" do @@ -54,7 +54,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!', position: position } - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -64,7 +64,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{diff_note.discussion_id}/notes", user), params: { body: 'hi!' } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['body']).to eq('hi!') expect(json_response['type']).to eq('DiffNote') end diff --git a/spec/support/shared_examples/requests/api/discussions.rb b/spec/support/shared_examples/requests/api/discussions.rb index 2a5a48f3054..232c8d20025 100644 --- a/spec/support/shared_examples/requests/api/discussions.rb +++ b/spec/support/shared_examples/requests/api/discussions.rb @@ -23,7 +23,7 @@ shared_examples 'with cross-reference system notes' do it 'returns only the note that the user should see' do get api(url, user, personal_access_token: pat) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response.count).to eq(1) expect(notes_in_response.count).to eq(1) @@ -40,7 +40,7 @@ shared_examples 'with cross-reference system notes' do get api(url, user, personal_access_token: pat) end - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) RequestStore.clear! @@ -50,7 +50,7 @@ shared_examples 'with cross-reference system notes' do RequestStore.clear! expect { get api(url, user, personal_access_token: pat) }.not_to exceed_query_limit(control) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) end end @@ -59,7 +59,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r it "returns an array of discussions" do get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['id']).to eq(note.discussion_id) @@ -68,7 +68,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r it "returns a 404 error when noteable id not found" do get api("/#{parent_type}/#{parent.id}/#{noteable_type}/12345/discussions", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it "returns 404 when not authorized" do @@ -76,7 +76,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", private_user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -84,7 +84,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r it "returns a discussion by id" do 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(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq(note.discussion_id) expect(json_response['notes'].first['body']).to eq(note.note) end @@ -92,7 +92,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r it "returns a 404 error if discussion not found" do get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/12345", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -100,7 +100,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r it "creates a new note" do 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(response).to have_gitlab_http_status(:created) expect(json_response['notes'].first['body']).to eq('hi!') expect(json_response['notes'].first['author']['username']).to eq(user.username) end @@ -108,13 +108,13 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r it "returns a 400 bad request error if body not given" do post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) 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!' } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it 'tracks a Notes::CreateService event' do @@ -146,7 +146,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!', created_at: creation_time } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) 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) @@ -162,7 +162,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", private_user), params: { body: 'Foo' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -181,7 +181,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r end it 'raises 404 error' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -191,7 +191,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r end it 'raises 404 error' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -203,7 +203,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}/notes", user), params: { body: 'Hello!' } - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['body']).to eq('Hello!') expect(json_response['type']).to eq('DiscussionNote') end @@ -212,7 +212,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}/notes", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end context 'when the discussion is an individual note' do @@ -225,13 +225,13 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r if can_reply_to_individual_notes it 'creates a new discussion' do - expect(response).to have_gitlab_http_status(201) + expect(response).to have_gitlab_http_status(:created) expect(json_response['body']).to eq('hi!') expect(json_response['type']).to eq('DiscussionNote') end else it 'returns 400 bad request' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -242,7 +242,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}/notes/#{note.id}", user), params: { body: 'Hello!' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['body']).to eq('Hello!') end @@ -251,14 +251,14 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r "discussions/#{note.discussion_id}/notes/12345", user), params: { body: 'Hello!' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end 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) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -267,18 +267,18 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}/notes/#{note.id}", user) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) # Check if note is really deleted delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}/notes/#{note.id}", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end 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) + expect(response).to have_gitlab_http_status(:not_found) end it_behaves_like '412 response' do 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 9fe6288d53f..013b135235c 100644 --- a/spec/support/shared_examples/requests/api/issuable_participants_examples.rb +++ b/spec/support/shared_examples/requests/api/issuable_participants_examples.rb @@ -6,7 +6,7 @@ shared_examples 'issuable participants endpoint' do it 'returns participants' do get api("/projects/#{project.id}/#{area}/#{entity.iid}/participants", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(entity.participants.size) @@ -20,12 +20,12 @@ shared_examples 'issuable participants endpoint' 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) + expect(response).to have_gitlab_http_status(:not_found) end 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) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/support/shared_examples/requests/api/notes.rb b/spec/support/shared_examples/requests/api/notes.rb index 4ce78d885bc..a793c23b809 100644 --- a/spec/support/shared_examples/requests/api/notes.rb +++ b/spec/support/shared_examples/requests/api/notes.rb @@ -82,7 +82,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| it "returns an array of notes" do get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(note.note) @@ -91,7 +91,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| it "returns a 404 error when noteable id not found" do get api("/#{parent_type}/#{parent.id}/#{noteable_type}/12345/notes", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it "returns 404 when not authorized" do @@ -99,7 +99,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -107,14 +107,14 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| it "returns a note by id" do get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/#{note.id}", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['body']).to eq(note.note) end it "returns a 404 error if note not found" do get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -122,7 +122,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| it "creates a new note" do 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(response).to have_gitlab_http_status(:created) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -130,13 +130,13 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| it "returns a 400 bad request error if body not given" do post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) 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!' } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) end it "creates an activity event when a note is created", :sidekiq_might_not_need_inline do @@ -154,7 +154,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| 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(response).to have_gitlab_http_status(:created) 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) @@ -167,7 +167,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| 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(response).to have_gitlab_http_status(:created) 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) @@ -185,7 +185,7 @@ 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(response).to have_gitlab_http_status(:created) 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) @@ -197,7 +197,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| 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(response).to have_gitlab_http_status(:created) 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) @@ -212,7 +212,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| 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(response).to have_gitlab_http_status(:created) 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) @@ -226,7 +226,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| parent.add_developer(private_user) 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(response).to have_gitlab_http_status(:created) expect(json_response['body']).to eq(':+1:') end end @@ -235,7 +235,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| 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(response).to have_gitlab_http_status(:created) expect(json_response['body']).to eq(':+1:') end end @@ -249,7 +249,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user), params: { body: 'Foo' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -259,7 +259,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "notes/#{note.id}", user), params: { body: 'Hello!' } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['body']).to eq('Hello!') end @@ -267,14 +267,14 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user), params: { body: 'Hello!' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end 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) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -283,17 +283,17 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "notes/#{note.id}", user) - expect(response).to have_gitlab_http_status(204) + expect(response).to have_gitlab_http_status(:no_content) # Check if note is really deleted delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "notes/#{note.id}", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end 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) + expect(response).to have_gitlab_http_status(:not_found) end it_behaves_like '412 response' do diff --git a/spec/support/shared_examples/requests/api/resolvable_discussions.rb b/spec/support/shared_examples/requests/api/resolvable_discussions.rb index 42054a273f3..dd764cf2d4d 100644 --- a/spec/support/shared_examples/requests/api/resolvable_discussions.rb +++ b/spec/support/shared_examples/requests/api/resolvable_discussions.rb @@ -6,7 +6,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}", user), params: { resolved: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['notes'].size).to eq(1) expect(json_response['notes'][0]['resolved']).to eq(true) end @@ -15,7 +15,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}", user), params: { resolved: false } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['notes'].size).to eq(1) expect(json_response['notes'][0]['resolved']).to eq(false) end @@ -24,21 +24,21 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}", user) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end 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 } - expect(response).to have_gitlab_http_status(401) + expect(response).to have_gitlab_http_status(:unauthorized) 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 } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end context 'when user does not have access to read the discussion' do @@ -50,7 +50,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}", private_user), params: { resolved: true } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -60,7 +60,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ "discussions/#{note.discussion_id}/notes/#{note.id}", user), params: { resolved: true } - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['resolved']).to eq(true) end @@ -69,21 +69,21 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ "discussions/#{note.discussion_id}/notes/12345", user), params: { body: 'Hello!' } - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end 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) - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) end 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 } - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end 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 ed9964fa108..d5845863a58 100644 --- a/spec/support/shared_examples/requests/api/status_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/status_shared_examples.rb @@ -13,7 +13,7 @@ shared_examples_for '400 response' do end it 'returns 400' do - expect(response).to have_gitlab_http_status(400) + expect(response).to have_gitlab_http_status(:bad_request) if message.present? expect(json_response['message']).to eq(message) @@ -28,7 +28,7 @@ shared_examples_for '403 response' do end it 'returns 403' do - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -41,7 +41,7 @@ shared_examples_for '404 response' do end it 'returns 404' do - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) expect(json_response).to be_an Object if message.present? @@ -60,7 +60,7 @@ shared_examples_for '412 response' do end it 'returns 412 with a JSON error' do - expect(response).to have_gitlab_http_status(412) + expect(response).to have_gitlab_http_status(:precondition_failed) expect(json_response).to eq('message' => '412 Precondition Failed') end end diff --git a/spec/support/shared_examples/requests/rack_attack_shared_examples.rb b/spec/support/shared_examples/requests/rack_attack_shared_examples.rb index c078e982e87..a864f3ac652 100644 --- a/spec/support/shared_examples/requests/rack_attack_shared_examples.rb +++ b/spec/support/shared_examples/requests/rack_attack_shared_examples.rb @@ -33,7 +33,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do # At first, allow requests under the rate limit. requests_per_period.times do make_request(request_args) - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end # the last straw @@ -43,7 +43,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do it 'allows requests after throttling and then waiting for the next period' do requests_per_period.times do make_request(request_args) - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end expect_rejection { make_request(request_args) } @@ -51,7 +51,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do Timecop.travel(period.from_now) do requests_per_period.times do make_request(request_args) - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end expect_rejection { make_request(request_args) } @@ -61,18 +61,18 @@ shared_examples_for 'rate-limited token-authenticated requests' do it 'counts requests from different users separately, even from the same IP' do requests_per_period.times do make_request(request_args) - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end # would be over the limit if this wasn't a different user make_request(other_user_request_args) - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end it 'counts all requests from the same user, even via different IPs' do requests_per_period.times do make_request(request_args) - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4') @@ -83,7 +83,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do it 'logs RackAttack info into structured logs' do requests_per_period.times do make_request(request_args) - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end arguments = { @@ -112,7 +112,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do it 'allows requests over the rate limit' do (1 + requests_per_period).times do make_request(request_args) - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end end end @@ -160,7 +160,7 @@ shared_examples_for 'rate-limited web authenticated requests' do # At first, allow requests under the rate limit. requests_per_period.times do request_authenticated_web_url - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end # the last straw @@ -170,7 +170,7 @@ shared_examples_for 'rate-limited web authenticated requests' do it 'allows requests after throttling and then waiting for the next period' do requests_per_period.times do request_authenticated_web_url - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end expect_rejection { request_authenticated_web_url } @@ -178,7 +178,7 @@ shared_examples_for 'rate-limited web authenticated requests' do Timecop.travel(period.from_now) do requests_per_period.times do request_authenticated_web_url - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end expect_rejection { request_authenticated_web_url } @@ -188,20 +188,20 @@ shared_examples_for 'rate-limited web authenticated requests' do it 'counts requests from different users separately, even from the same IP' do requests_per_period.times do request_authenticated_web_url - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end # would be over the limit if this wasn't a different user login_as(create(:user)) request_authenticated_web_url - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end it 'counts all requests from the same user, even via different IPs' do requests_per_period.times do request_authenticated_web_url - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4') @@ -212,7 +212,7 @@ shared_examples_for 'rate-limited web authenticated requests' do it 'logs RackAttack info into structured logs' do requests_per_period.times do request_authenticated_web_url - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end arguments = { @@ -241,7 +241,7 @@ shared_examples_for 'rate-limited web authenticated requests' do it 'allows requests over the rate limit' do (1 + requests_per_period).times do request_authenticated_web_url - expect(response).not_to have_http_status 429 + expect(response).not_to have_gitlab_http_status(:too_many_requests) end end end diff --git a/spec/support/shared_examples/resource_label_events_api.rb b/spec/support/shared_examples/resource_label_events_api.rb index 6622df78ee2..d3d9b83764d 100644 --- a/spec/support/shared_examples/resource_label_events_api.rb +++ b/spec/support/shared_examples/resource_label_events_api.rb @@ -8,7 +8,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ it "returns an array of resource label events" do get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events", user) - expect(response).to have_gitlab_http_status(200) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['id']).to eq(event.id) @@ -17,7 +17,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ it "returns a 404 error when eventable id not found" do get api("/#{parent_type}/#{parent.id}/#{eventable_type}/12345/resource_label_events", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it "returns 404 when not authorized" do @@ -26,7 +26,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events", private_user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -60,7 +60,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ it "returns a resource label event by id" 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(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq(event.id) end @@ -70,13 +70,13 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{event.id}", private_user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end it "returns a 404 error if resource label event not found" do get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/12345", user) - expect(response).to have_gitlab_http_status(404) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -88,7 +88,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ it "returns a 404 error if cross-reference project is not accessible" 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(404) + expect(response).to have_gitlab_http_status(:not_found) end end 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 9bdfa762fc8..17777f2cc93 100644 --- a/spec/support/shared_examples/unique_ip_check_shared_examples.rb +++ b/spec/support/shared_examples/unique_ip_check_shared_examples.rb @@ -69,7 +69,7 @@ shared_examples 'user login request with unique ip limit' do |success_status = 2 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) + expect(request_from_ip('ip2')).to have_gitlab_http_status(:forbidden) end end end -- cgit v1.2.3