diff --git a/CHANGELOG.md b/CHANGELOG.md index 578651639c5..6bca9944bb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,7 +100,7 @@ entry. - [CHANGED] Added defaults for protected branches dropdowns on the repository settings. !14278 - [CHANGED] Show confirmation modal before deleting account. !14360 - [CHANGED] Allow creating merge requests across a fork network. !14422 -- [CHANGED] Re-arrange + + diff --git a/app/assets/javascripts/repo/components/new_dropdown/index.vue b/app/assets/javascripts/repo/components/new_dropdown/index.vue new file mode 100644 index 00000000000..3ccb50213ab --- /dev/null +++ b/app/assets/javascripts/repo/components/new_dropdown/index.vue @@ -0,0 +1,86 @@ + + + diff --git a/app/assets/javascripts/repo/components/new_dropdown/modal.vue b/app/assets/javascripts/repo/components/new_dropdown/modal.vue new file mode 100644 index 00000000000..5ef629e0dde --- /dev/null +++ b/app/assets/javascripts/repo/components/new_dropdown/modal.vue @@ -0,0 +1,90 @@ + + + diff --git a/app/assets/javascripts/repo/components/repo.vue b/app/assets/javascripts/repo/components/repo.vue index 0a89a9f16cb..788976a9804 100644 --- a/app/assets/javascripts/repo/components/repo.vue +++ b/app/assets/javascripts/repo/components/repo.vue @@ -8,7 +8,9 @@ import RepoMixin from '../mixins/repo_mixin'; import PopupDialog from '../../vue_shared/components/popup_dialog.vue'; import Store from '../stores/repo_store'; import Helper from '../helpers/repo_helper'; +import Service from '../services/repo_service'; import MonacoLoaderHelper from '../helpers/monaco_loader_helper'; +import eventHub from '../event_hub'; export default { data() { @@ -24,12 +26,19 @@ export default { PopupDialog, RepoPreview, }, - + created() { + eventHub.$on('createNewBranch', this.createNewBranch); + }, mounted() { Helper.getContent().catch(Helper.loadingError); }, - + destroyed() { + eventHub.$off('createNewBranch', this.createNewBranch); + }, methods: { + getCurrentLocation() { + return location.href; + }, toggleDialogOpen(toggle) { this.dialog.open = toggle; }, @@ -37,9 +46,30 @@ export default { dialogSubmitted(status) { this.toggleDialogOpen(false); this.dialog.status = status; - }, + // remove tmp files + Helper.removeAllTmpFiles('openedFiles'); + Helper.removeAllTmpFiles('files'); + }, toggleBlobView: Store.toggleBlobView, + createNewBranch(branch) { + Service.createBranch({ + branch, + ref: Store.currentBranch, + }).then((res) => { + const newBranchName = res.data.name; + const newUrl = this.getCurrentLocation().replace(Store.currentBranch, newBranchName); + + Store.currentBranch = newBranchName; + + history.pushState({ key: Helper.key }, '', newUrl); + + eventHub.$emit('createNewBranchSuccess', newBranchName); + eventHub.$emit('toggleNewBranchDropdown'); + }).catch((err) => { + eventHub.$emit('createNewBranchError', err.response.data.message); + }); + }, }, }; diff --git a/app/assets/javascripts/repo/components/repo_commit_section.vue b/app/assets/javascripts/repo/components/repo_commit_section.vue index 185cd90ac06..0d6259a37a8 100644 --- a/app/assets/javascripts/repo/components/repo_commit_section.vue +++ b/app/assets/javascripts/repo/components/repo_commit_section.vue @@ -49,7 +49,7 @@ export default { // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions const commitMessage = this.commitMessage; const actions = this.changedFiles.map(f => ({ - action: 'update', + action: f.tempFile ? 'create' : 'update', file_path: f.path, content: f.newContent, })); @@ -62,7 +62,6 @@ export default { if (newBranch) { payload.start_branch = this.currentBranch; } - this.submitCommitsLoading = true; Service.commitFiles(payload) .then(() => { this.resetCommitState(); @@ -78,6 +77,8 @@ export default { }, tryCommit(e, skipBranchCheck = false, newBranch = false) { + this.submitCommitsLoading = true; + if (skipBranchCheck) { this.makeCommit(newBranch); } else { @@ -90,6 +91,7 @@ export default { this.makeCommit(newBranch); }) .catch(() => { + this.submitCommitsLoading = false; Flash('An error occurred while committing your changes'); }); } diff --git a/app/assets/javascripts/repo/components/repo_editor.vue b/app/assets/javascripts/repo/components/repo_editor.vue index 4639bee6d66..df4caba51d8 100644 --- a/app/assets/javascripts/repo/components/repo_editor.vue +++ b/app/assets/javascripts/repo/components/repo_editor.vue @@ -16,7 +16,7 @@ const RepoEditor = { }, mounted() { - Service.getRaw(this.activeFile.raw_path) + Service.getRaw(this.activeFile) .then((rawResponse) => { Store.blobRaw = rawResponse.data; Store.activeFile.plain = rawResponse.data; diff --git a/app/assets/javascripts/repo/components/repo_file_buttons.vue b/app/assets/javascripts/repo/components/repo_file_buttons.vue index 03cd219e718..c98f641c853 100644 --- a/app/assets/javascripts/repo/components/repo_file_buttons.vue +++ b/app/assets/javascripts/repo/components/repo_file_buttons.vue @@ -11,7 +11,12 @@ const RepoFileButtons = { mixins: [RepoMixin], computed: { - + showButtons() { + return this.activeFile.raw_path || + this.activeFile.blame_path || + this.activeFile.commits_path || + this.activeFile.permalink; + }, rawDownloadButtonLabel() { return this.binary ? 'Download' : 'Raw'; }, @@ -30,7 +35,10 @@ export default RepoFileButtons; diff --git a/app/assets/javascripts/vue_shared/components/ci_badge_link.vue b/app/assets/javascripts/vue_shared/components/ci_badge_link.vue index caa28bff6db..5b6c6e8d0b9 100644 --- a/app/assets/javascripts/vue_shared/components/ci_badge_link.vue +++ b/app/assets/javascripts/vue_shared/components/ci_badge_link.vue @@ -1,52 +1,64 @@ diff --git a/app/assets/javascripts/vue_shared/components/commit.vue b/app/assets/javascripts/vue_shared/components/commit.vue index 50d14282cad..52814de8b2d 100644 --- a/app/assets/javascripts/vue_shared/components/commit.vue +++ b/app/assets/javascripts/vue_shared/components/commit.vue @@ -63,14 +63,17 @@ required: false, default: () => ({}), }, + showBranch: { + type: Boolean, + required: false, + default: true, + }, }, computed: { /** * Used to verify if all the properties needed to render the commit * ref section were provided. * - * TODO: Improve this! Use lodash _.has when we have it. - * * @returns {Boolean} */ hasCommitRef() { @@ -80,8 +83,6 @@ * Used to verify if all the properties needed to render the commit * author section were provided. * - * TODO: Improve this! Use lodash _.has when we have it. - * * @returns {Boolean} */ hasAuthor() { @@ -114,31 +115,30 @@ diff --git a/app/assets/stylesheets/framework.scss b/app/assets/stylesheets/framework.scss index aa61ddc6a2c..7b1ef003bb2 100644 --- a/app/assets/stylesheets/framework.scss +++ b/app/assets/stylesheets/framework.scss @@ -5,6 +5,7 @@ @import "framework/layout"; @import "framework/animations"; +@import "framework/vue_transitions"; @import "framework/avatar"; @import "framework/asciidoctor"; @import "framework/banner"; @@ -36,7 +37,7 @@ @import "framework/secondary-navigation-elements"; @import "framework/selects"; @import "framework/sidebar"; -@import "framework/new-sidebar"; +@import "framework/contextual-sidebar"; @import "framework/tables"; @import "framework/notes"; @import "framework/tabs"; diff --git a/app/assets/stylesheets/framework/buttons.scss b/app/assets/stylesheets/framework/buttons.scss index b131e2d57ee..00a0e9cef67 100644 --- a/app/assets/stylesheets/framework/buttons.scss +++ b/app/assets/stylesheets/framework/buttons.scss @@ -292,6 +292,11 @@ } } +.btn-align-content { + display: flex; + align-items: center; +} + .btn-group { &.btn-grouped { @include btn-with-margin; diff --git a/app/assets/stylesheets/framework/new-sidebar.scss b/app/assets/stylesheets/framework/contextual-sidebar.scss similarity index 86% rename from app/assets/stylesheets/framework/new-sidebar.scss rename to app/assets/stylesheets/framework/contextual-sidebar.scss index 7a309f2c8a1..fa5d3833f3e 100644 --- a/app/assets/stylesheets/framework/new-sidebar.scss +++ b/app/assets/stylesheets/framework/contextual-sidebar.scss @@ -1,24 +1,10 @@ -@import "framework/variables"; -@import 'framework/tw_bootstrap_variables'; -@import "bootstrap/variables"; - -$active-background: rgba(0, 0, 0, .04); -$active-hover-background: $active-background; -$active-hover-color: $gl-text-color; -$inactive-badge-background: rgba(0, 0, 0, .08); -$hover-background: rgba(0, 0, 0, .06); -$hover-color: $gl-text-color; -$inactive-color: $gl-text-color-secondary; -$new-sidebar-width: 220px; -$new-sidebar-collapsed-width: 50px; - -.page-with-new-sidebar { +.page-with-contextual-sidebar { @media (min-width: $screen-md-min) { - padding-left: $new-sidebar-collapsed-width; + padding-left: $contextual-sidebar-collapsed-width; } @media (min-width: $screen-lg-min) { - padding-left: $new-sidebar-width; + padding-left: $contextual-sidebar-width; } // Override position: absolute @@ -34,7 +20,7 @@ $new-sidebar-collapsed-width: 50px; .page-with-icon-sidebar { @media (min-width: $screen-sm-min) { - padding-left: $new-sidebar-collapsed-width; + padding-left: $contextual-sidebar-collapsed-width; } } @@ -52,12 +38,12 @@ $new-sidebar-collapsed-width: 50px; &:hover, a:hover { - background-color: $hover-background; - color: $hover-color; + background-color: $link-hover-background; + color: $gl-text-color; .settings-avatar { svg { - fill: $hover-color; + fill: $gl-text-color; } } } @@ -85,7 +71,7 @@ $new-sidebar-collapsed-width: 50px; .nav-sidebar { position: fixed; z-index: 400; - width: $new-sidebar-width; + width: $contextual-sidebar-width; transition: left $sidebar-transition-duration; top: $header-height; bottom: 0; @@ -103,7 +89,7 @@ $new-sidebar-collapsed-width: 50px; &.sidebar-icons-only { width: auto; - min-width: $new-sidebar-collapsed-width; + min-width: $contextual-sidebar-collapsed-width; .nav-sidebar-inner-scroll { overflow-x: hidden; @@ -149,11 +135,11 @@ $new-sidebar-collapsed-width: 50px; display: flex; align-items: center; padding: 12px 16px; - color: $inactive-color; + color: $gl-text-color-secondary; } svg { - fill: $inactive-color; + fill: $gl-text-color-secondary; } } @@ -168,7 +154,7 @@ $new-sidebar-collapsed-width: 50px; } @media (max-width: $screen-xs-max) { - left: (-$new-sidebar-width); + left: (-$contextual-sidebar-width); } .nav-icon-container { @@ -210,8 +196,8 @@ $new-sidebar-collapsed-width: 50px; &:hover, &:focus { - background: $active-hover-background; - color: $active-hover-color; + background: $link-active-background; + color: $gl-text-color; } } @@ -220,7 +206,7 @@ $new-sidebar-collapsed-width: 50px; &, &:hover, &:focus { - background: $active-background; + background: $link-active-background; } } } @@ -308,11 +294,11 @@ $new-sidebar-collapsed-width: 50px; .badge { background-color: $inactive-badge-background; - color: $inactive-color; + color: $gl-text-color-secondary; } &.active { - background: $active-background; + background: $link-active-background; > a { margin-left: 4px; @@ -330,7 +316,7 @@ $new-sidebar-collapsed-width: 50px; &.active > a:hover, &.is-over > a { - background-color: $hover-background; + background-color: $link-hover-background; } } } @@ -340,7 +326,7 @@ $new-sidebar-collapsed-width: 50px; .toggle-sidebar-button, .close-nav-button { - width: $new-sidebar-width - 2px; + width: $contextual-sidebar-width - 2px; position: fixed; bottom: 0; padding: 16px; @@ -407,7 +393,7 @@ $new-sidebar-collapsed-width: 50px; } .toggle-sidebar-button { - width: $new-sidebar-collapsed-width - 2px; + width: $contextual-sidebar-collapsed-width - 2px; padding: 16px; .collapse-text, diff --git a/app/assets/stylesheets/framework/filters.scss b/app/assets/stylesheets/framework/filters.scss index b2847c348eb..0d80a85d521 100644 --- a/app/assets/stylesheets/framework/filters.scss +++ b/app/assets/stylesheets/framework/filters.scss @@ -65,7 +65,7 @@ display: flex; flex: 1; -webkit-flex: 1; - padding-left: 30px; + padding-left: 12px; position: relative; margin-bottom: 0; } @@ -221,10 +221,6 @@ box-shadow: 0 0 4px $search-input-focus-shadow-color; } - &.focus .fa-filter { - color: $common-gray-dark; - } - gl-emoji { display: inline-block; font-family: inherit; @@ -251,13 +247,6 @@ } } - .fa-filter { - position: absolute; - top: 10px; - left: 10px; - color: $gray-darkest; - } - .fa-times { right: 10px; color: $gray-darkest; diff --git a/app/assets/stylesheets/framework/variables.scss b/app/assets/stylesheets/framework/variables.scss index d5ca23ff870..8ab48e4844f 100644 --- a/app/assets/stylesheets/framework/variables.scss +++ b/app/assets/stylesheets/framework/variables.scss @@ -9,6 +9,8 @@ $sidebar-transition-duration: .15s; $sidebar-breakpoint: 1024px; $default-transition-duration: .15s; $right-sidebar-transition-duration: .3s; +$contextual-sidebar-width: 220px; +$contextual-sidebar-collapsed-width: 50px; /* * Color schema @@ -358,6 +360,13 @@ $dropdown-item-hover-bg: $gray-darker; $filtered-search-term-shadow-color: rgba(0, 0, 0, 0.09); $dropdown-hover-color: $blue-400; +/* +* Contextual Sidebar +*/ +$link-active-background: rgba(0, 0, 0, .04); +$link-hover-background: rgba(0, 0, 0, .06); +$inactive-badge-background: rgba(0, 0, 0, .08); + /* * Buttons */ @@ -404,7 +413,6 @@ $note-targe3-inside: #ffffd3; $note-line2-border: #ddd; $note-icon-gutter-width: 55px; - /* * Zen */ diff --git a/app/assets/stylesheets/framework/vue_transitions.scss b/app/assets/stylesheets/framework/vue_transitions.scss new file mode 100644 index 00000000000..e07a177e153 --- /dev/null +++ b/app/assets/stylesheets/framework/vue_transitions.scss @@ -0,0 +1,9 @@ +.fade-enter-active, +.fade-leave-active { + transition: opacity $sidebar-transition-duration $general-hover-transition-curve; +} + +.fade-enter, +.fade-leave-to { + opacity: 0; +} diff --git a/app/assets/stylesheets/pages/boards.scss b/app/assets/stylesheets/pages/boards.scss index ca61f7a30c3..91296b354a7 100644 --- a/app/assets/stylesheets/pages/boards.scss +++ b/app/assets/stylesheets/pages/boards.scss @@ -414,7 +414,7 @@ margin: 5px; } -.page-with-new-sidebar.page-with-sidebar .issue-boards-sidebar { +.page-with-contextual-sidebar.page-with-sidebar .issue-boards-sidebar { .issuable-sidebar-header { position: relative; } diff --git a/app/assets/stylesheets/pages/note_form.scss b/app/assets/stylesheets/pages/note_form.scss index 04b132415eb..f0cad30f4f3 100644 --- a/app/assets/stylesheets/pages/note_form.scss +++ b/app/assets/stylesheets/pages/note_form.scss @@ -249,13 +249,12 @@ width: 100%; padding-right: 5px; } - } .discussion-actions { display: table; - .new-issue-for-discussion path { + .btn-default path { fill: $gray-darkest; } diff --git a/app/assets/stylesheets/pages/notes.scss b/app/assets/stylesheets/pages/notes.scss index ebad429c2ba..3bd0e3ad535 100644 --- a/app/assets/stylesheets/pages/notes.scss +++ b/app/assets/stylesheets/pages/notes.scss @@ -466,6 +466,10 @@ ul.notes { float: right; margin-left: 10px; color: $gray-darkest; + + .btn-group > .discussion-next-btn { + margin-left: -1px; + } } .note-actions { diff --git a/app/assets/stylesheets/pages/repo.scss b/app/assets/stylesheets/pages/repo.scss index ea37ccf5e3d..6a363b1710e 100644 --- a/app/assets/stylesheets/pages/repo.scss +++ b/app/assets/stylesheets/pages/repo.scss @@ -1,8 +1,3 @@ -.fade-enter-active, -.fade-leave-active { - transition: opacity $sidebar-transition-duration; -} - .monaco-loader { position: absolute; top: 0; @@ -206,7 +201,7 @@ } } - #repo-file-buttons { + .repo-file-buttons { background-color: $white-light; padding: 5px 10px; border-top: 1px solid $white-normal; diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb index 572915a4930..38f379dbf4f 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -57,6 +57,10 @@ class HelpController < ApplicationController def shortcuts end + def instance_configuration + @instance_configuration = InstanceConfiguration.new + end + def ui @user = User.new(id: 0, name: 'John Doe', username: '@johndoe') end diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index 183a6f88a6a..770381472c5 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -205,6 +205,7 @@ class Projects::BlobController < Projects::ApplicationController tree_path = path_segments.join('/') render json: json.merge( + id: @blob.id, path: blob.path, name: blob.name, extension: blob.extension, diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb index 7f03ce07dec..f28df83d5a5 100644 --- a/app/controllers/projects/branches_controller.rb +++ b/app/controllers/projects/branches_controller.rb @@ -15,6 +15,8 @@ class Projects::BranchesController < Projects::ApplicationController respond_to do |format| format.html do @refs_pipelines = @project.pipelines.latest_successful_for_refs(@branches.map(&:name)) + @merged_branch_names = + repository.merged_branch_names(@branches.map(&:name)) # n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37429 Gitlab::GitalyClient.allow_n_plus_1_calls do @max_commits = @branches.reduce(0) do |memo, branch| diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index b7a108a0ebd..fe1334c0cfe 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -16,7 +16,7 @@ class Projects::IssuesController < Projects::ApplicationController before_action :authorize_create_issue!, only: [:new, :create] # Allow modify issue - before_action :authorize_update_issue!, only: [:update, :move] + before_action :authorize_update_issue!, only: [:edit, :update, :move] # Allow create a new branch and empty WIP merge request from current issue before_action :authorize_create_merge_request!, only: [:create_merge_request] @@ -63,6 +63,10 @@ class Projects::IssuesController < Projects::ApplicationController respond_with(@issue) end + def edit + respond_with(@issue) + end + def show @noteable = @issue @note = @project.notes.new(noteable: @issue) @@ -122,6 +126,10 @@ class Projects::IssuesController < Projects::ApplicationController @issue = Issues::UpdateService.new(project, current_user, update_params).execute(issue) respond_to do |format| + format.html do + recaptcha_check_with_fallback { render :edit } + end + format.json do render_issue_json end diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb index 756f7e5df8c..f3719059f88 100644 --- a/app/controllers/projects/tree_controller.rb +++ b/app/controllers/projects/tree_controller.rb @@ -36,7 +36,6 @@ class Projects::TreeController < Projects::ApplicationController format.json do page_title @path.presence || _("Files"), @ref, @project.name_with_namespace - response.header['is-root'] = @path.empty? # n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38261 Gitlab::GitalyClient.allow_n_plus_1_calls do diff --git a/app/finders/branches_finder.rb b/app/finders/branches_finder.rb index 533076585c0..852eac3647d 100644 --- a/app/finders/branches_finder.rb +++ b/app/finders/branches_finder.rb @@ -23,7 +23,7 @@ class BranchesFinder def filter_by_name(branches) if search - branches.select { |branch| branch.name.include?(search) } + branches.select { |branch| branch.name.upcase.include?(search.upcase) } else branches end diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 1ee8911bb1a..cd1ecaadb85 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -120,6 +120,15 @@ module ApplicationSettingsHelper message.html_safe end + def circuitbreaker_access_retries_help_text + _('The number of attempts GitLab will make to access a storage.') + end + + def circuitbreaker_backoff_threshold_help_text + _("The number of failures after which GitLab will start temporarily "\ + "disabling access to a storage shard on a host") + end + def circuitbreaker_failure_wait_time_help_text _("When access to a storage fails. GitLab will prevent access to the "\ "storage for the time specified here. This allows the filesystem to "\ @@ -144,6 +153,8 @@ module ApplicationSettingsHelper :akismet_api_key, :akismet_enabled, :auto_devops_enabled, + :circuitbreaker_access_retries, + :circuitbreaker_backoff_threshold, :circuitbreaker_failure_count_threshold, :circuitbreaker_failure_reset_time, :circuitbreaker_failure_wait_time, diff --git a/app/helpers/instance_configuration_helper.rb b/app/helpers/instance_configuration_helper.rb new file mode 100644 index 00000000000..cee319f20bc --- /dev/null +++ b/app/helpers/instance_configuration_helper.rb @@ -0,0 +1,18 @@ +module InstanceConfigurationHelper + def instance_configuration_cell_html(value, &block) + return '-' unless value.to_s.presence + + block_given? ? yield(value) : value + end + + def instance_configuration_host(host) + @instance_configuration_host ||= instance_configuration_cell_html(host).capitalize + end + + # Value must be in bytes + def instance_configuration_human_size_cell(value) + instance_configuration_cell_html(value) do |v| + number_to_human_size(v, strip_insignificant_zeros: true, significant: false) + end + end +end diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index a23a43c9f43..5a74511afa7 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -1,7 +1,7 @@ module NavHelper def page_with_sidebar_class class_name = page_gutter_class - class_name << 'page-with-new-sidebar' if defined?(@left_sidebar) && @left_sidebar + class_name << 'page-with-contextual-sidebar' if defined?(@left_sidebar) && @left_sidebar class_name << 'page-with-icon-sidebar' if collapsed_sidebar? && @left_sidebar class_name diff --git a/app/helpers/storage_health_helper.rb b/app/helpers/storage_health_helper.rb index 544c9efb845..4d2180f7eee 100644 --- a/app/helpers/storage_health_helper.rb +++ b/app/helpers/storage_health_helper.rb @@ -16,17 +16,16 @@ module StorageHealthHelper def message_for_circuit_breaker(circuit_breaker) maximum_failures = circuit_breaker.failure_count_threshold current_failures = circuit_breaker.failure_count - permanently_broken = circuit_breaker.circuit_broken? && current_failures >= maximum_failures translation_params = { number_of_failures: current_failures, maximum_failures: maximum_failures, number_of_seconds: circuit_breaker.failure_wait_time } - if permanently_broken + if circuit_breaker.circuit_broken? s_("%{number_of_failures} of %{maximum_failures} failures. GitLab will not "\ "retry automatically. Reset storage information when the problem is "\ "resolved.") % translation_params - elsif circuit_breaker.circuit_broken? + elsif circuit_breaker.backing_off? _("%{number_of_failures} of %{maximum_failures} failures. GitLab will "\ "block access for %{number_of_seconds} seconds.") % translation_params else diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 4dda276bb41..f266e7db6da 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -153,13 +153,25 @@ class ApplicationSetting < ActiveRecord::Base presence: true, numericality: { greater_than_or_equal_to: 0 } - validates :circuitbreaker_failure_count_threshold, + validates :circuitbreaker_backoff_threshold, + :circuitbreaker_failure_count_threshold, :circuitbreaker_failure_wait_time, :circuitbreaker_failure_reset_time, :circuitbreaker_storage_timeout, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } + validates :circuitbreaker_access_retries, + presence: true, + numericality: { only_integer: true, greater_than_or_equal_to: 1 } + + validates_each :circuitbreaker_backoff_threshold do |record, attr, value| + if value.to_i >= record.circuitbreaker_failure_count_threshold + record.errors.add(attr, _("The circuitbreaker backoff threshold should be "\ + "lower than the failure count threshold")) + end + end + SUPPORTED_KEY_TYPES.each do |type| validates :"#{type}_key_restriction", presence: true, key_restriction: { type: type } end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index cf3ce3c9e54..ca65e81f27a 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -249,9 +249,7 @@ module Ci end def commit - @commit ||= project.commit(sha) - rescue - nil + @commit ||= project.commit_by(oid: sha) end def branch? diff --git a/app/models/environment.rb b/app/models/environment.rb index b6868ccbe8f..e613d21add6 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -110,7 +110,7 @@ class Environment < ActiveRecord::Base end def ref_path - "refs/#{Repository::REF_ENVIRONMENTS}/#{Shellwords.shellescape(name)}" + "refs/#{Repository::REF_ENVIRONMENTS}/#{generate_slug}" end def formatted_external_url diff --git a/app/models/instance_configuration.rb b/app/models/instance_configuration.rb new file mode 100644 index 00000000000..b30b707e5fe --- /dev/null +++ b/app/models/instance_configuration.rb @@ -0,0 +1,71 @@ +require 'resolv' + +class InstanceConfiguration + SSH_ALGORITHMS = %w(DSA ECDSA ED25519 RSA).freeze + SSH_ALGORITHMS_PATH = '/etc/ssh/'.freeze + CACHE_KEY = 'instance_configuration'.freeze + EXPIRATION_TIME = 24.hours + + def settings + @configuration ||= Rails.cache.fetch(CACHE_KEY, expires_in: EXPIRATION_TIME) do + { ssh_algorithms_hashes: ssh_algorithms_hashes, + host: host, + gitlab_pages: gitlab_pages, + gitlab_ci: gitlab_ci }.deep_symbolize_keys + end + end + + private + + def ssh_algorithms_hashes + SSH_ALGORITHMS.map { |algo| ssh_algorithm_hashes(algo) }.compact + end + + def host + Settings.gitlab.host + end + + def gitlab_pages + Settings.pages.to_h.merge(ip_address: resolv_dns(Settings.pages.host)) + end + + def resolv_dns(dns) + Resolv.getaddress(dns) + rescue Resolv::ResolvError + end + + def gitlab_ci + Settings.gitlab_ci + .to_h + .merge(artifacts_max_size: { value: Settings.artifacts.max_size&.megabytes, + default: 100.megabytes }) + end + + def ssh_algorithm_file(algorithm) + File.join(SSH_ALGORITHMS_PATH, "ssh_host_#{algorithm.downcase}_key.pub") + end + + def ssh_algorithm_hashes(algorithm) + content = ssh_algorithm_file_content(algorithm) + return unless content.present? + + { name: algorithm, + md5: ssh_algorithm_md5(content), + sha256: ssh_algorithm_sha256(content) } + end + + def ssh_algorithm_file_content(algorithm) + file = ssh_algorithm_file(algorithm) + return unless File.exist?(file) + + File.read(file) + end + + def ssh_algorithm_md5(ssh_file_content) + OpenSSL::Digest::MD5.hexdigest(ssh_file_content).scan(/../).join(':') + end + + def ssh_algorithm_sha256(ssh_file_content) + OpenSSL::Digest::SHA256.hexdigest(ssh_file_content) + end +end diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb index 5d798247863..2e824cda525 100644 --- a/app/models/pages_domain.rb +++ b/app/models/pages_domain.rb @@ -16,9 +16,9 @@ class PagesDomain < ActiveRecord::Base key: Gitlab::Application.secrets.db_key_base, algorithm: 'aes-256-cbc' - after_create :update - after_save :update - after_destroy :update + after_create :update_daemon + after_save :update_daemon + after_destroy :update_daemon def to_param domain @@ -80,7 +80,7 @@ class PagesDomain < ActiveRecord::Base private - def update + def update_daemon ::Projects::UpdatePagesConfigurationService.new(project).execute end diff --git a/app/models/project.rb b/app/models/project.rb index 4689b588906..7185b4d44fc 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -540,6 +540,10 @@ class Project < ActiveRecord::Base repository.commit(ref) end + def commit_by(oid:) + repository.commit_by(oid: oid) + end + # ref can't be HEAD, can only be branch/tag name or SHA def latest_successful_builds_for(ref = default_branch) latest_pipeline = pipelines.latest_successful_for(ref) @@ -553,7 +557,7 @@ class Project < ActiveRecord::Base def merge_base_commit(first_commit_id, second_commit_id) sha = repository.merge_base(first_commit_id, second_commit_id) - repository.commit(sha) if sha + commit_by(oid: sha) if sha end def saved? diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index 9ee3a533c1e..b487378edd2 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -3,6 +3,8 @@ class JiraService < IssueTrackerService validates :url, url: true, presence: true, if: :activated? validates :api_url, url: true, allow_blank: true + validates :username, presence: true, if: :activated? + validates :password, presence: true, if: :activated? prop_accessor :username, :password, :url, :api_url, :jira_issue_transition_id, :title, :description diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb index 8ba07173c74..5c0b3338a62 100644 --- a/app/models/project_services/kubernetes_service.rb +++ b/app/models/project_services/kubernetes_service.rb @@ -153,7 +153,10 @@ class KubernetesService < DeploymentService end def default_namespace - "#{project.path}-#{project.id}" if project.present? + return unless project + + slug = "#{project.path}-#{project.id}".downcase + slug.gsub(/[^-a-z0-9]/, '-').gsub(/^-+/, '') end def build_kubeclient!(api_path: 'api', api_version: 'v1') diff --git a/app/models/repository.rb b/app/models/repository.rb index 4324ea46aac..44a1e9ce529 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -76,6 +76,7 @@ class Repository @full_path = full_path @disk_path = disk_path || full_path @project = project + @commit_cache = {} end def ==(other) @@ -103,18 +104,17 @@ class Repository def commit(ref = 'HEAD') return nil unless exists? + return ref if ref.is_a?(::Commit) - commit = - if ref.is_a?(Gitlab::Git::Commit) - ref - else - Gitlab::Git::Commit.find(raw_repository, ref) - end + find_commit(ref) + end - commit = ::Commit.new(commit, @project) if commit - commit - rescue Rugged::OdbError, Rugged::TreeError - nil + # Finding a commit by the passed SHA + # Also takes care of caching, based on the SHA + def commit_by(oid:) + return @commit_cache[oid] if @commit_cache.key?(oid) + + @commit_cache[oid] = find_commit(oid) end def commits(ref, path: nil, limit: nil, offset: nil, skip_merges: false, after: nil, before: nil) @@ -231,7 +231,7 @@ class Repository # branches or tags, but we want to keep some of these commits around, for # example if they have comments or CI builds. def keep_around(sha) - return unless sha && commit(sha) + return unless sha && commit_by(oid: sha) return if kept_around?(sha) @@ -862,22 +862,12 @@ class Repository end def ff_merge(user, source, target_branch, merge_request: nil) - our_commit = rugged.branches[target_branch].target - their_commit = - if source.is_a?(Gitlab::Git::Commit) - source.raw_commit - else - rugged.lookup(source) - end + their_commit_id = commit(source)&.id + raise 'Invalid merge source' if their_commit_id.nil? - raise 'Invalid merge target' if our_commit.nil? - raise 'Invalid merge source' if their_commit.nil? + merge_request&.update(in_progress_merge_commit_sha: their_commit_id) - with_branch(user, target_branch) do |start_commit| - merge_request&.update(in_progress_merge_commit_sha: their_commit.oid) - - their_commit.oid - end + with_cache_hooks { raw.ff_merge(user, their_commit_id, target_branch) } end def revert( @@ -912,18 +902,27 @@ class Repository end end - def merged_to_root_ref?(branch_name) - branch_commit = commit(branch_name) - root_ref_commit = commit(root_ref) + def merged_to_root_ref?(branch_or_name, pre_loaded_merged_branches = nil) + branch = Gitlab::Git::Branch.find(self, branch_or_name) - if branch_commit - same_head = branch_commit.id == root_ref_commit.id - !same_head && ancestor?(branch_commit.id, root_ref_commit.id) + if branch + root_ref_sha = commit(root_ref).sha + same_head = branch.target == root_ref_sha + merged = + if pre_loaded_merged_branches + pre_loaded_merged_branches.include?(branch.name) + else + ancestor?(branch.target, root_ref_sha) + end + + !same_head && merged else nil end end + delegate :merged_branch_names, to: :raw_repository + def merge_base(first_commit_id, second_commit_id) first_commit_id = commit(first_commit_id).try(:id) || first_commit_id second_commit_id = commit(second_commit_id).try(:id) || second_commit_id @@ -1031,6 +1030,10 @@ class Repository if instance_variable_defined?(ivar) instance_variable_get(ivar) else + # If the repository doesn't exist and a fallback was specified we return + # that value inmediately. This saves us Rugged/gRPC invocations. + return fallback unless fallback.nil? || exists? + begin value = if memoize_only @@ -1040,8 +1043,9 @@ class Repository end instance_variable_set(ivar, value) rescue Rugged::ReferenceError, Gitlab::Git::Repository::NoRepository - # if e.g. HEAD or the entire repository doesn't exist we want to - # gracefully handle this and not cache anything. + # Even if the above `#exists?` check passes these errors might still + # occur (for example because of a non-existing HEAD). We want to + # gracefully handle this and not cache anything fallback end end @@ -1069,6 +1073,18 @@ class Repository private + # TODO Generice finder, later split this on finders by Ref or Oid + # gitlab-org/gitlab-ce#39239 + def find_commit(oid_or_ref) + commit = if oid_or_ref.is_a?(Gitlab::Git::Commit) + oid_or_ref + else + Gitlab::Git::Commit.find(raw_repository, oid_or_ref) + end + + ::Commit.new(commit, @project) if commit + end + def blob_data_at(sha, path) blob = blob_at(sha, path) return unless blob @@ -1107,12 +1123,12 @@ class Repository def last_commit_for_path_by_gitaly(sha, path) c = raw_repository.gitaly_commit_client.last_commit_for_path(sha, path) - commit(c) + commit_by(oid: c) end def last_commit_for_path_by_rugged(sha, path) sha = last_commit_id_for_path_by_shelling_out(sha, path) - commit(sha) + commit_by(oid: sha) end def last_commit_id_for_path_by_shelling_out(sha, path) diff --git a/app/services/users/last_push_event_service.rb b/app/services/users/last_push_event_service.rb index f2bfb60604f..57e446d7f30 100644 --- a/app/services/users/last_push_event_service.rb +++ b/app/services/users/last_push_event_service.rb @@ -16,8 +16,8 @@ module Users user_cache_key ] - if event.project.forked? - keys << project_cache_key(event.project.forked_from_project) + if forked_from = event.project.forked_from_project + keys << project_cache_key(forked_from) end keys.each { |key| set_key(key, event.id) } diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml index 2b23af9212e..3a4d5ce0b5c 100644 --- a/app/views/admin/application_settings/_form.html.haml +++ b/app/views/admin/application_settings/_form.html.haml @@ -533,29 +533,41 @@ %fieldset %legend Git Storage Circuitbreaker settings .form-group - = f.label :circuitbreaker_failure_count_threshold, _('Maximum git storage failures'), class: 'control-label col-sm-2' + = f.label :circuitbreaker_access_retries, _('Number of access attempts'), class: 'control-label col-sm-2' .col-sm-10 - = f.number_field :circuitbreaker_failure_count_threshold, class: 'form-control' + = f.number_field :circuitbreaker_access_retries, class: 'form-control' .help-block - = circuitbreaker_failure_count_help_text + = circuitbreaker_access_retries_help_text + .form-group + = f.label :circuitbreaker_storage_timeout, _('Seconds to wait for a storage access attempt'), class: 'control-label col-sm-2' + .col-sm-10 + = f.number_field :circuitbreaker_storage_timeout, class: 'form-control' + .help-block + = circuitbreaker_storage_timeout_help_text + .form-group + = f.label :circuitbreaker_backoff_threshold, _('Number of failures before backing off'), class: 'control-label col-sm-2' + .col-sm-10 + = f.number_field :circuitbreaker_backoff_threshold, class: 'form-control' + .help-block + = circuitbreaker_backoff_threshold_help_text .form-group = f.label :circuitbreaker_failure_wait_time, _('Seconds to wait after a storage failure'), class: 'control-label col-sm-2' .col-sm-10 = f.number_field :circuitbreaker_failure_wait_time, class: 'form-control' .help-block = circuitbreaker_failure_wait_time_help_text + .form-group + = f.label :circuitbreaker_failure_count_threshold, _('Maximum git storage failures'), class: 'control-label col-sm-2' + .col-sm-10 + = f.number_field :circuitbreaker_failure_count_threshold, class: 'form-control' + .help-block + = circuitbreaker_failure_count_help_text .form-group = f.label :circuitbreaker_failure_reset_time, _('Seconds before reseting failure information'), class: 'control-label col-sm-2' .col-sm-10 = f.number_field :circuitbreaker_failure_reset_time, class: 'form-control' .help-block = circuitbreaker_failure_reset_time_help_text - .form-group - = f.label :circuitbreaker_storage_timeout, _('Seconds to wait for a storage access attempt'), class: 'control-label col-sm-2' - .col-sm-10 - = f.number_field :circuitbreaker_storage_timeout, class: 'form-control' - .help-block - = circuitbreaker_storage_timeout_help_text %fieldset %legend Repository Checks diff --git a/app/views/dashboard/_projects_head.html.haml b/app/views/dashboard/_projects_head.html.haml index fd2ba9ac1ca..9038c4fbebd 100644 --- a/app/views/dashboard/_projects_head.html.haml +++ b/app/views/dashboard/_projects_head.html.haml @@ -6,13 +6,13 @@ .fade-right= icon('angle-right') %ul.nav-links.scrolling-tabs = nav_link(page: [dashboard_projects_path, root_path]) do - = link_to dashboard_projects_path, title: 'Home', class: 'shortcuts-activity', data: {placement: 'right'} do + = link_to dashboard_projects_path, class: 'shortcuts-activity', data: {placement: 'right'} do Your projects = nav_link(page: starred_dashboard_projects_path) do - = link_to starred_dashboard_projects_path, title: 'Starred Projects', data: {placement: 'right'} do + = link_to starred_dashboard_projects_path, data: {placement: 'right'} do Starred projects = nav_link(page: [explore_root_path, trending_explore_projects_path, starred_explore_projects_path, explore_projects_path]) do - = link_to explore_root_path, title: 'Explore', data: {placement: 'right'} do + = link_to explore_root_path, data: {placement: 'right'} do Explore projects .nav-controls diff --git a/app/views/help/index.html.haml b/app/views/help/index.html.haml index c25eae63eec..d0c2e0b1d69 100644 --- a/app/views/help/index.html.haml +++ b/app/views/help/index.html.haml @@ -11,6 +11,7 @@ %span= Gitlab::VERSION %small= link_to Gitlab::REVISION, Gitlab::COM_URL + namespace_project_commits_path('gitlab-org', 'gitlab-ce', Gitlab::REVISION) = version_status_badge + %p.slead GitLab is open source software to collaborate on code. %br @@ -23,6 +24,7 @@ Used by more than 100,000 organizations, GitLab is the most popular solution to manage git repositories on-premises. %br Read more about GitLab at #{link_to promo_host, promo_url, target: '_blank', rel: 'noopener noreferrer'}. + %p= link_to 'Check the current instance configuration ', help_instance_configuration_url %hr .row.prepend-top-default diff --git a/app/views/help/instance_configuration.html.haml b/app/views/help/instance_configuration.html.haml new file mode 100644 index 00000000000..f09e3825a4b --- /dev/null +++ b/app/views/help/instance_configuration.html.haml @@ -0,0 +1,17 @@ +- page_title 'Instance Configuration' +.wiki.documentation + %h1 Instance Configuration + + %p + In this page you will find information about the settings that are used in your current instance. + + = render 'help/instance_configuration/ssh_info' + = render 'help/instance_configuration/gitlab_pages' + = render 'help/instance_configuration/gitlab_ci' + %p + %strong Table of contents + + %ul + = content_for :table_content + + = content_for :settings_content diff --git a/app/views/help/instance_configuration/_gitlab_ci.html.haml b/app/views/help/instance_configuration/_gitlab_ci.html.haml new file mode 100644 index 00000000000..7fa8bd086d4 --- /dev/null +++ b/app/views/help/instance_configuration/_gitlab_ci.html.haml @@ -0,0 +1,24 @@ +- content_for :table_content do + %li= link_to 'GitLab CI', '#gitlab-ci' + +- content_for :settings_content do + %h2#gitlab-ci + GitLab CI + + %p + Below are the current settings regarding + = succeed('.') { link_to('GitLab CI', 'https://about.gitlab.com/gitlab-ci', target: '_blank') } + + .table-responsive + %table + %thead + %tr + %th Setting + %th= instance_configuration_host(@instance_configuration.settings[:host]) + %th Default + %tbody + %tr + - artifacts_size = @instance_configuration.settings[:gitlab_ci][:artifacts_max_size] + %td Artifacts maximum size + %td= instance_configuration_human_size_cell(artifacts_size[:value]) + %td= instance_configuration_human_size_cell(artifacts_size[:default]) diff --git a/app/views/help/instance_configuration/_gitlab_pages.html.haml b/app/views/help/instance_configuration/_gitlab_pages.html.haml new file mode 100644 index 00000000000..bdd77730dcc --- /dev/null +++ b/app/views/help/instance_configuration/_gitlab_pages.html.haml @@ -0,0 +1,35 @@ +- gitlab_pages = @instance_configuration.settings[:gitlab_pages] +- content_for :table_content do + %li= link_to 'GitLab Pages', '#gitlab-pages' + +- content_for :settings_content do + %h2#gitlab-pages + GitLab Pages + + %p + Below are the settings for + = succeed('.') { link_to('Gitlab Pages', gitlab_pages[:url], target: '_blank') } + .table-responsive + %table + %thead + %tr + %th Setting + %th= instance_configuration_host(@instance_configuration.settings[:host]) + %tbody + %tr + %td Domain Name + %td + %code= instance_configuration_cell_html(gitlab_pages[:host]) + %tr + %td IP Address + %td + %code= instance_configuration_cell_html(gitlab_pages[:ip_address]) + %tr + %td Port + %td + %code= instance_configuration_cell_html(gitlab_pages[:port]) + %br + + %p + The maximum size of your Pages site is regulated by the artifacts maximum + size which is part of #{succeed('.') { link_to('GitLab CI', '#gitlab-ci') }} diff --git a/app/views/help/instance_configuration/_ssh_info.html.haml b/app/views/help/instance_configuration/_ssh_info.html.haml new file mode 100644 index 00000000000..987cc61b3f6 --- /dev/null +++ b/app/views/help/instance_configuration/_ssh_info.html.haml @@ -0,0 +1,27 @@ +- ssh_info = @instance_configuration.settings[:ssh_algorithms_hashes] +- if ssh_info.any? + - content_for :table_content do + %li= link_to 'SSH host keys fingerprints', '#ssh-host-keys-fingerprints' + + - content_for :settings_content do + %h2#ssh-host-keys-fingerprints + SSH host keys fingerprints + + %p + Below are the fingerprints for the current instance SSH host keys. + + .table-responsive + %table + %thead + %tr + %th Algorithm + %th MD5 + %th SHA256 + %tbody + - ssh_info.each do |algorithm| + %tr + %td= algorithm[:name] + %td + %code= instance_configuration_cell_html(algorithm[:md5]) + %td + %code= instance_configuration_cell_html(algorithm[:sha256]) diff --git a/app/views/peek/views/_gitaly.html.haml b/app/views/peek/views/_gitaly.html.haml new file mode 100644 index 00000000000..a7d040d6821 --- /dev/null +++ b/app/views/peek/views/_gitaly.html.haml @@ -0,0 +1,7 @@ +- local_assigns.fetch(:view) + +%strong + %span{ data: { defer_to: "#{view.defer_key}-duration" } } ... + \/ + %span{ data: { defer_to: "#{view.defer_key}-calls" } } ... + Gitaly diff --git a/app/views/projects/branches/_branch.html.haml b/app/views/projects/branches/_branch.html.haml index 49101d1efa4..6e02ae6c9cc 100644 --- a/app/views/projects/branches/_branch.html.haml +++ b/app/views/projects/branches/_branch.html.haml @@ -1,3 +1,4 @@ +- merged = local_assigns.fetch(:merged, false) - commit = @repository.commit(branch.dereferenced_target) - bar_graph_width_factor = @max_commits > 0 ? 100.0/@max_commits : 0 - diverging_commit_counts = @repository.diverging_commit_counts(branch) @@ -12,7 +13,7 @@   - if branch.name == @repository.root_ref %span.label.label-primary default - - elsif @repository.merged_to_root_ref? branch.name + - elsif merged %span.label.label-info.has-tooltip{ title: s_('Branches|Merged into %{default_branch}') % { default_branch: @repository.root_ref } } = s_('Branches|merged') @@ -47,7 +48,7 @@ target: "#modal-delete-branch", delete_path: project_branch_path(@project, branch.name), branch_name: branch.name, - is_merged: ("true" if @repository.merged_to_root_ref?(branch.name)) } } + is_merged: ("true" if merged) } } = icon("trash-o") - else %button{ class: "btn btn-remove remove-row js-ajax-loading-spinner has-tooltip disabled", diff --git a/app/views/projects/branches/index.html.haml b/app/views/projects/branches/index.html.haml index 7d9645d79e6..aade310236e 100644 --- a/app/views/projects/branches/index.html.haml +++ b/app/views/projects/branches/index.html.haml @@ -38,7 +38,7 @@ - if @branches.any? %ul.content-list.all-branches - @branches.each do |branch| - = render "projects/branches/branch", branch: branch + = render "projects/branches/branch", branch: branch, merged: @repository.merged_to_root_ref?(branch, @merged_branch_names) = paginate @branches, theme: 'gitlab' - else .nothing-here-block diff --git a/app/views/projects/clusters/show.html.haml b/app/views/projects/clusters/show.html.haml index ff76abc3553..b127e06030e 100644 --- a/app/views/projects/clusters/show.html.haml +++ b/app/views/projects/clusters/show.html.haml @@ -47,7 +47,7 @@ - if can?(current_user, :update_cluster, @cluster) .form-group - = field.submit s_('ClusterIntegration|Save'), class: 'btn btn-success' + = field.submit _('Save'), class: 'btn btn-success' %section.settings#js-cluster-details .settings-header @@ -68,7 +68,7 @@ %section.settings#js-cluster-advanced-settings .settings-header - %h4= s_('ClusterIntegration|Advanced settings') + %h4= _('Advanced settings') %button.btn.js-settings-toggle = expanded ? 'Collapse' : 'Expand' %p= s_('ClusterIntegration|Manage Cluster integration on your GitLab project') diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index 09bcd187e59..ff17372fdd9 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -77,5 +77,6 @@ #{ n_(s_('Pipeline|with stage'), s_('Pipeline|with stages'), last_pipeline.stages_count) } .mr-widget-pipeline-graph = render 'shared/mini_pipeline_graph', pipeline: last_pipeline, klass: 'js-commit-pipeline-graph' - in - = time_interval_in_words last_pipeline.duration + - if last_pipeline.duration + in + = time_interval_in_words last_pipeline.duration diff --git a/app/views/projects/empty.html.haml b/app/views/projects/empty.html.haml index c9956183e12..af564b93dc3 100644 --- a/app/views/projects/empty.html.haml +++ b/app/views/projects/empty.html.haml @@ -72,6 +72,7 @@ %pre.light-well :preserve cd existing_repo + git remote rename origin old-origin git remote add origin #{ content_tag(:span, default_url_to_repo, class: 'clone')} git push -u origin --all git push -u origin --tags diff --git a/app/views/projects/issues/edit.html.haml b/app/views/projects/issues/edit.html.haml new file mode 100644 index 00000000000..1b7d878c38c --- /dev/null +++ b/app/views/projects/issues/edit.html.haml @@ -0,0 +1,7 @@ +- page_title "Edit", "#{@issue.title} (#{@issue.to_reference})", "Issues" + +%h3.page-title + Edit Issue ##{@issue.iid} +%hr + += render "form" diff --git a/app/views/projects/tree/_tree_header.html.haml b/app/views/projects/tree/_tree_header.html.haml index 6cddc38d11a..7ea19e6c828 100644 --- a/app/views/projects/tree/_tree_header.html.haml +++ b/app/views/projects/tree/_tree_header.html.haml @@ -1,8 +1,10 @@ .tree-ref-container .tree-ref-holder - = render 'shared/ref_switcher', destination: 'tree', path: @path + = render 'shared/ref_switcher', destination: 'tree', path: @path, show_create: true - - unless show_new_repo? + - if show_new_repo? + .js-new-dropdown + - else = render 'projects/tree/old_tree_header' .tree-controls diff --git a/app/views/shared/_ref_switcher.html.haml b/app/views/shared/_ref_switcher.html.haml index 7ad743b3b81..6d7c9633913 100644 --- a/app/views/shared/_ref_switcher.html.haml +++ b/app/views/shared/_ref_switcher.html.haml @@ -1,3 +1,4 @@ +- show_new_branch_form = show_new_repo? && show_create && can?(current_user, :push_code, @project) - dropdown_toggle_text = @ref || @project.default_branch = form_tag switch_project_refs_path(@project), method: :get, class: "project-refs-form" do = hidden_field_tag :destination, destination @@ -7,8 +8,20 @@ = hidden_field_tag key, value, id: nil .dropdown = dropdown_toggle dropdown_toggle_text, { toggle: "dropdown", selected: dropdown_toggle_text, ref: @ref, refs_url: refs_project_path(@project), field_name: 'ref', submit_form_on_click: true, visit: true }, { toggle_class: "js-project-refs-dropdown" } - .dropdown-menu.dropdown-menu-selectable.git-revision-dropdown{ class: ("dropdown-menu-align-right" if local_assigns[:align_right]) } - = dropdown_title _("Switch branch/tag") - = dropdown_filter _("Search branches and tags") - = dropdown_content - = dropdown_loading + .dropdown-menu.dropdown-menu-selectable.git-revision-dropdown.dropdown-menu-paging{ class: ("dropdown-menu-align-right" if local_assigns[:align_right]) } + .dropdown-page-one + = dropdown_title _("Switch branch/tag") + = dropdown_filter _("Search branches and tags") + = dropdown_content + = dropdown_loading + - if show_new_branch_form + = dropdown_footer do + %ul.dropdown-footer-list + %li + %a.dropdown-toggle-page{ href: "#" } + Create new branch + - if show_new_branch_form + .dropdown-page-two + = dropdown_title("Create new branch", options: { back: true }) + = dropdown_content do + .js-new-branch-dropdown diff --git a/app/views/shared/issuable/_participants.html.haml b/app/views/shared/issuable/_participants.html.haml index d2b62557e03..3f553c9fede 100644 --- a/app/views/shared/issuable/_participants.html.haml +++ b/app/views/shared/issuable/_participants.html.haml @@ -14,5 +14,5 @@ = link_to_member(@project, participant, name: false, size: 24, lazy_load: true) - if participants_extra > 0 .hide-collapsed.participants-more - %a.js-participants-more{ href: "#", data: { original_text: "+ #{participants_size - 7} more", less_text: "- show less" } } + %button.btn-transparent.btn-blank.js-participants-more{ type: 'button', data: { original_text: "+ #{participants_size - 7} more", less_text: "- show less" } } + #{participants_extra} more diff --git a/app/views/shared/issuable/_search_bar.html.haml b/app/views/shared/issuable/_search_bar.html.haml index 161b1c9fd72..fabb17c7340 100644 --- a/app/views/shared/issuable/_search_bar.html.haml +++ b/app/views/shared/issuable/_search_bar.html.haml @@ -25,7 +25,6 @@ %ul.tokens-container.list-unstyled %li.input-token %input.form-control.filtered-search{ search_filter_input_options(type) } - = icon('filter') #js-dropdown-hint.filtered-search-input-dropdown-menu.dropdown-menu.hint-dropdown %ul{ data: { dropdown: true } } %li.filter-dropdown-item{ data: { action: 'submit' } } diff --git a/app/views/shared/repo/_repo.html.haml b/app/views/shared/repo/_repo.html.haml index 7185f5bcc5b..7861f92b33f 100644 --- a/app/views/shared/repo/_repo.html.haml +++ b/app/views/shared/repo/_repo.html.haml @@ -7,4 +7,5 @@ blob_url: namespace_project_blob_path(project.namespace, project, '{{branch}}'), new_mr_template_url: namespace_project_new_merge_request_path(project.namespace, project, merge_request: { source_branch: '{{source_branch}}' }), can_commit: (!!can_push_branch?(project, @ref)).to_s, - on_top_of_branch: (!!on_top_of_branch?(project, @ref)).to_s } } + on_top_of_branch: (!!on_top_of_branch?(project, @ref)).to_s, + current_path: @path } } diff --git a/changelogs/unreleased/14970-suggest-rename-remote.yml b/changelogs/unreleased/14970-suggest-rename-remote.yml new file mode 100644 index 00000000000..68a77eb446d --- /dev/null +++ b/changelogs/unreleased/14970-suggest-rename-remote.yml @@ -0,0 +1,5 @@ +--- +title: Suggest to rename the remote for existing repository instructions +merge_request: 14970 +author: helmo42 +type: added diff --git a/changelogs/unreleased/23000-pages-api.yml b/changelogs/unreleased/23000-pages-api.yml new file mode 100644 index 00000000000..9f6fa13dd07 --- /dev/null +++ b/changelogs/unreleased/23000-pages-api.yml @@ -0,0 +1,5 @@ +--- +title: Add API endpoints for Pages Domains +merge_request: 13917 +author: Travis Miller +type: added diff --git a/changelogs/unreleased/32318-filter-icon.yml b/changelogs/unreleased/32318-filter-icon.yml new file mode 100644 index 00000000000..71e7c2c4dac --- /dev/null +++ b/changelogs/unreleased/32318-filter-icon.yml @@ -0,0 +1,5 @@ +--- +title: Remove filter icon from search bar +merge_request: +author: +type: other diff --git a/changelogs/unreleased/35199-case-insensitive-branches-search.yml b/changelogs/unreleased/35199-case-insensitive-branches-search.yml new file mode 100644 index 00000000000..da2729e9e55 --- /dev/null +++ b/changelogs/unreleased/35199-case-insensitive-branches-search.yml @@ -0,0 +1,5 @@ +--- +title: Case insensitive search for branches +merge_request: 14995 +author: George Andrinopoulos +type: fixed diff --git a/changelogs/unreleased/35644-refactor-have-http-status-into-have-gitlab-http-status.yml b/changelogs/unreleased/35644-refactor-have-http-status-into-have-gitlab-http-status.yml new file mode 100644 index 00000000000..b03baab4950 --- /dev/null +++ b/changelogs/unreleased/35644-refactor-have-http-status-into-have-gitlab-http-status.yml @@ -0,0 +1,5 @@ +--- +title: Refactor have_http_status into have_gitlab_http_status +merge_request: 14958 +author: Jacopo Beschi @jacopo-beschi +type: added diff --git a/changelogs/unreleased/38178-fl-mr-notes-components.yml b/changelogs/unreleased/38178-fl-mr-notes-components.yml new file mode 100644 index 00000000000..244ccfb3071 --- /dev/null +++ b/changelogs/unreleased/38178-fl-mr-notes-components.yml @@ -0,0 +1,6 @@ +--- +title: Moves placeholders components into shared folder with documentation. Makes + them easier to reuse in MR and Snippets comments +merge_request: +author: +type: other diff --git a/changelogs/unreleased/39188-change-default-disabled-merge-message.yml b/changelogs/unreleased/39188-change-default-disabled-merge-message.yml new file mode 100644 index 00000000000..7de65f5c3f6 --- /dev/null +++ b/changelogs/unreleased/39188-change-default-disabled-merge-message.yml @@ -0,0 +1,5 @@ +--- +title: Update default disabled merge request widget message to reflect a general failure +merge_request: 14960 +author: +type: changed diff --git a/changelogs/unreleased/39419-remove-overzealous-tooltips.yml b/changelogs/unreleased/39419-remove-overzealous-tooltips.yml new file mode 100644 index 00000000000..d6cf60bebfa --- /dev/null +++ b/changelogs/unreleased/39419-remove-overzealous-tooltips.yml @@ -0,0 +1,5 @@ +--- +title: Remove overzealous tooltips in projects page tabs +merge_request: 15017 +author: +type: removed diff --git a/changelogs/unreleased/39441-bring-edit-form-back.yml b/changelogs/unreleased/39441-bring-edit-form-back.yml new file mode 100644 index 00000000000..025417e4da9 --- /dev/null +++ b/changelogs/unreleased/39441-bring-edit-form-back.yml @@ -0,0 +1,5 @@ +--- +title: Fix editing issue description in mobile view +merge_request: +author: +type: fixed diff --git a/changelogs/unreleased/39495-fix-bitbucket-login.yml b/changelogs/unreleased/39495-fix-bitbucket-login.yml new file mode 100644 index 00000000000..b48d557108b --- /dev/null +++ b/changelogs/unreleased/39495-fix-bitbucket-login.yml @@ -0,0 +1,5 @@ +--- +title: Fix bitbucket login +merge_request: 15051 +author: +type: fixed diff --git a/changelogs/unreleased/add-shared-vue-loading-button.yml b/changelogs/unreleased/add-shared-vue-loading-button.yml new file mode 100644 index 00000000000..a8904acc4e7 --- /dev/null +++ b/changelogs/unreleased/add-shared-vue-loading-button.yml @@ -0,0 +1,5 @@ +--- +title: Add loading button for new UX paradigm +merge_request: 14883 +author: +type: added diff --git a/changelogs/unreleased/api-configure-jira.yml b/changelogs/unreleased/api-configure-jira.yml new file mode 100644 index 00000000000..3ac52d573b0 --- /dev/null +++ b/changelogs/unreleased/api-configure-jira.yml @@ -0,0 +1,5 @@ +--- +title: Validate username/pw for Jiraservice, require them in the API +merge_request: 15025 +author: Robert Schilling +type: fixed diff --git a/changelogs/unreleased/api-doc-group-statistics.yml b/changelogs/unreleased/api-doc-group-statistics.yml new file mode 100644 index 00000000000..385ff978024 --- /dev/null +++ b/changelogs/unreleased/api-doc-group-statistics.yml @@ -0,0 +1,5 @@ +--- +title: Update the groups API documentation +merge_request: 15024 +author: Robert Schilling +type: fixed diff --git a/changelogs/unreleased/bvl-circuitbreaker-backoff.yml b/changelogs/unreleased/bvl-circuitbreaker-backoff.yml new file mode 100644 index 00000000000..5cb90e7c085 --- /dev/null +++ b/changelogs/unreleased/bvl-circuitbreaker-backoff.yml @@ -0,0 +1,6 @@ +--- +title: Make the circuitbreaker more robust by adding higher thresholds, and multiple + access attempts. +merge_request: 14933 +author: +type: fixed diff --git a/changelogs/unreleased/bvl-dont-rename-free-names.yml b/changelogs/unreleased/bvl-dont-rename-free-names.yml new file mode 100644 index 00000000000..60a4ec8afbe --- /dev/null +++ b/changelogs/unreleased/bvl-dont-rename-free-names.yml @@ -0,0 +1,5 @@ +--- +title: Don't rename paths that were freed up when upgrading +merge_request: 15029 +author: +type: fixed diff --git a/changelogs/unreleased/bvl-fix-push-event-service-for-forks.yml b/changelogs/unreleased/bvl-fix-push-event-service-for-forks.yml new file mode 100644 index 00000000000..2a7d80270ac --- /dev/null +++ b/changelogs/unreleased/bvl-fix-push-event-service-for-forks.yml @@ -0,0 +1,5 @@ +--- +title: Only cache last push event for existing projects when pushing to a fork +merge_request: 14989 +author: +type: fixed diff --git a/changelogs/unreleased/feature-ssh_host_fingerprint.yml b/changelogs/unreleased/feature-ssh_host_fingerprint.yml new file mode 100644 index 00000000000..04f9fd1d6ed --- /dev/null +++ b/changelogs/unreleased/feature-ssh_host_fingerprint.yml @@ -0,0 +1,5 @@ +--- +title: Automatic configuration settings page +merge_request: 13850 +author: Francisco Lopez +type: added diff --git a/changelogs/unreleased/fix-add-path-attr-to-wiki-file.yml b/changelogs/unreleased/fix-add-path-attr-to-wiki-file.yml new file mode 100644 index 00000000000..0847b5f6733 --- /dev/null +++ b/changelogs/unreleased/fix-add-path-attr-to-wiki-file.yml @@ -0,0 +1,5 @@ +--- +title: Fix broken wiki pages that link to a wiki file +merge_request: 15019 +author: +type: fixed diff --git a/changelogs/unreleased/hide-pipeline-zero-duration.yml b/changelogs/unreleased/hide-pipeline-zero-duration.yml new file mode 100644 index 00000000000..5d7a0983537 --- /dev/null +++ b/changelogs/unreleased/hide-pipeline-zero-duration.yml @@ -0,0 +1,5 @@ +--- +title: Hides pipeline duration in commit box when it is zero (nil) +merge_request: 14979 +author: gvieira37 +type: fixed diff --git a/changelogs/unreleased/mr-14642.yml b/changelogs/unreleased/mr-14642.yml new file mode 100644 index 00000000000..048cc79e323 --- /dev/null +++ b/changelogs/unreleased/mr-14642.yml @@ -0,0 +1,6 @@ +--- +title: Auto Devops kubernetes default namespace is now correctly built out of gitlab + project group-name +merge_request: 14642 +author: Mircea Danila Dumitrescu +type: fixed diff --git a/changelogs/unreleased/sh-fix-environment-write-ref.yml b/changelogs/unreleased/sh-fix-environment-write-ref.yml new file mode 100644 index 00000000000..8f291843ebe --- /dev/null +++ b/changelogs/unreleased/sh-fix-environment-write-ref.yml @@ -0,0 +1,5 @@ +--- +title: Fix the writing of invalid environment refs +merge_request: +author: +type: fixed diff --git a/changelogs/unreleased/sh-memoize-logger.yml b/changelogs/unreleased/sh-memoize-logger.yml new file mode 100644 index 00000000000..1b6567ce72f --- /dev/null +++ b/changelogs/unreleased/sh-memoize-logger.yml @@ -0,0 +1,5 @@ +--- +title: Memoize GitLab logger to reduce open file descriptors +merge_request: +author: +type: fixed diff --git a/changelogs/unreleased/use-git-branch-merged.yml b/changelogs/unreleased/use-git-branch-merged.yml new file mode 100644 index 00000000000..24ec226250c --- /dev/null +++ b/changelogs/unreleased/use-git-branch-merged.yml @@ -0,0 +1,5 @@ +--- +title: Improve branch listing page performance +merge_request: 14729 +author: +type: performance diff --git a/changelogs/unreleased/zj-commit-cache.yml b/changelogs/unreleased/zj-commit-cache.yml new file mode 100644 index 00000000000..e3afe0ea7ef --- /dev/null +++ b/changelogs/unreleased/zj-commit-cache.yml @@ -0,0 +1,5 @@ +--- +title: Cache commits fetched from the repository +merge_request: +author: +type: performance diff --git a/changelogs/unreleased/zj-peek-gitaly.yml b/changelogs/unreleased/zj-peek-gitaly.yml new file mode 100644 index 00000000000..bd2f2a07540 --- /dev/null +++ b/changelogs/unreleased/zj-peek-gitaly.yml @@ -0,0 +1,5 @@ +--- +title: Add Gitaly metrics to the performance bar +merge_request: +author: +type: other diff --git a/config/initializers/peek.rb b/config/initializers/peek.rb index a54d53cbbe2..1cff355346c 100644 --- a/config/initializers/peek.rb +++ b/config/initializers/peek.rb @@ -16,6 +16,7 @@ Peek.into Peek::Views::Redis Peek.into Peek::Views::Sidekiq Peek.into Peek::Views::Rblineprof Peek.into Peek::Views::GC +Peek.into Peek::Views::Gitaly # rubocop:disable Style/ClassAndModuleCamelCase class PEEK_DB_CLIENT diff --git a/config/routes/group.rb b/config/routes/group.rb index 702df5b7b5a..f4d520a2518 100644 --- a/config/routes/group.rb +++ b/config/routes/group.rb @@ -4,51 +4,51 @@ resources :groups, only: [:index, :new, :create] do post :preview_markdown end -scope(path: 'groups/*group_id', - module: :groups, - as: :group, - constraints: { group_id: Gitlab::PathRegex.full_namespace_route_regex }) do - resources :group_members, only: [:index, :create, :update, :destroy], concerns: :access_requestable do - post :resend_invite, on: :member - delete :leave, on: :collection - end - - resource :avatar, only: [:destroy] - resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :edit, :update, :new, :create] do - member do - get :merge_requests - get :participants - get :labels - end - end - - resources :labels, except: [:show] do - post :toggle_subscription, on: :member - end - - scope path: '-' do - namespace :settings do - resource :ci_cd, only: [:show], controller: 'ci_cd' - end - - resources :variables, only: [:index, :show, :update, :create, :destroy] - - resources :children, only: [:index] - end -end - -scope(path: 'groups/*id', - controller: :groups, - constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ }) do - get :edit, as: :edit_group - get :issues, as: :issues_group - get :merge_requests, as: :merge_requests_group - get :projects, as: :projects_group - get :activity, as: :activity_group - get '/', action: :show, as: :group_canonical -end - constraints(GroupUrlConstrainer.new) do + scope(path: 'groups/*id', + controller: :groups, + constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ }) do + get :edit, as: :edit_group + get :issues, as: :issues_group + get :merge_requests, as: :merge_requests_group + get :projects, as: :projects_group + get :activity, as: :activity_group + get '/', action: :show, as: :group_canonical + end + + scope(path: 'groups/*group_id', + module: :groups, + as: :group, + constraints: { group_id: Gitlab::PathRegex.full_namespace_route_regex }) do + resources :group_members, only: [:index, :create, :update, :destroy], concerns: :access_requestable do + post :resend_invite, on: :member + delete :leave, on: :collection + end + + resource :avatar, only: [:destroy] + resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :edit, :update, :new, :create] do + member do + get :merge_requests + get :participants + get :labels + end + end + + resources :labels, except: [:show] do + post :toggle_subscription, on: :member + end + + scope path: '-' do + namespace :settings do + resource :ci_cd, only: [:show], controller: 'ci_cd' + end + + resources :variables, only: [:index, :show, :update, :create, :destroy] + + resources :children, only: [:index] + end + end + scope(path: '*id', as: :group, constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ }, diff --git a/config/routes/help.rb b/config/routes/help.rb index d53822da9ec..2ea8bfd7aed 100644 --- a/config/routes/help.rb +++ b/config/routes/help.rb @@ -1,4 +1,5 @@ -get 'help' => 'help#index' -get 'help/shortcuts' => 'help#shortcuts' -get 'help/ui' => 'help#ui' -get 'help/*path' => 'help#show', as: :help_page +get 'help' => 'help#index' +get 'help/shortcuts' => 'help#shortcuts' +get 'help/ui' => 'help#ui' +get 'help/instance_configuration' => 'help#instance_configuration' +get 'help/*path' => 'help#show', as: :help_page diff --git a/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb b/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb new file mode 100644 index 00000000000..07eb25c0b0f --- /dev/null +++ b/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb @@ -0,0 +1,16 @@ +class AddNewCircuitbreakerSettingsToApplicationSettings < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :application_settings, + :circuitbreaker_access_retries, + :integer, + default: 3 + add_column :application_settings, + :circuitbreaker_backoff_threshold, + :integer, + default: 80 + end +end diff --git a/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb b/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb index 9441b236c8d..2125cc046e5 100644 --- a/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb +++ b/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb @@ -13,7 +13,6 @@ class RenameAllReservedPathsAgain < ActiveRecord::Migration .well-known abuse_reports admin - all api assets autocomplete @@ -24,29 +23,20 @@ class RenameAllReservedPathsAgain < ActiveRecord::Migration groups health_check help - hooks import invites - issues jwt koding - member - merge_requests - new - notes notification_settings oauth profile projects public - repository robots.txt s search sent_notifications - services snippets - teams u unicorn_test unsubscribes @@ -94,7 +84,6 @@ class RenameAllReservedPathsAgain < ActiveRecord::Migration notification_setting pipeline_quota projects - subgroups ].freeze def up diff --git a/db/schema.rb b/db/schema.rb index c2c04873d4d..530f08022be 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171012101043) do +ActiveRecord::Schema.define(version: 20171017145932) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -138,6 +138,8 @@ ActiveRecord::Schema.define(version: 20171012101043) do t.integer "circuitbreaker_failure_wait_time", default: 30 t.integer "circuitbreaker_failure_reset_time", default: 1800 t.integer "circuitbreaker_storage_timeout", default: 30 + t.integer "circuitbreaker_access_retries", default: 3 + t.integer "circuitbreaker_backoff_threshold", default: 80 end create_table "audit_events", force: :cascade do |t| diff --git a/doc/README.md b/doc/README.md index c6500a37aa9..5eabc126b95 100644 --- a/doc/README.md +++ b/doc/README.md @@ -85,7 +85,7 @@ Manage your [repositories](user/project/repository/index.md) from the UI (user i ### Issues and Merge Requests (MRs) -- [Discussions](user/discussions/index.md) Threads, comments, and resolvable discussions in issues, commits, and merge requests. +- [Discussions](user/discussions/index.md): Threads, comments, and resolvable discussions in issues, commits, and merge requests. - [Issues](user/project/issues/index.md) - [Project issue Board](user/project/issue_board.md) - [Issues and merge requests templates](user/project/description_templates.md): Create templates for submitting new issues and merge requests. @@ -155,7 +155,7 @@ have access to GitLab administration tools and settings. - [Git LFS configuration](workflow/lfs/lfs_administration.md): Learn how to use LFS under GitLab. - [GitLab Pages configuration](administration/pages/index.md): Configure GitLab Pages. - [High Availability](administration/high_availability/README.md): Configure multiple servers for scaling or high availability. -- [User cohorts](user/admin_area/user_cohorts.md) View user activity over time. +- [User cohorts](user/admin_area/user_cohorts.md): View user activity over time. - [Web terminals](administration/integration/terminal.md): Provide terminal access to environments from within GitLab. - GitLab CI - [CI admin settings](user/admin_area/settings/continuous_integration.md): Define max artifacts size and expiration time. diff --git a/doc/administration/img/circuitbreaker_config.png b/doc/administration/img/circuitbreaker_config.png index 9250d38297c..e811d173634 100644 Binary files a/doc/administration/img/circuitbreaker_config.png and b/doc/administration/img/circuitbreaker_config.png differ diff --git a/doc/administration/repository_storage_paths.md b/doc/administration/repository_storage_paths.md index efcabd69822..96f436fa7c3 100644 --- a/doc/administration/repository_storage_paths.md +++ b/doc/administration/repository_storage_paths.md @@ -109,6 +109,11 @@ This can be configured from the admin interface: ![circuitbreaker configuration](img/circuitbreaker_config.png) +**Number of access attempts**: The number of attempts GitLab will make to access a +storage when probing a shard. + +**Number of failures before backing off**: The number of failures after which +GitLab will start temporarily disabling access to a storage shard on a host. **Maximum git storage failures:** The number of failures of after which GitLab will completely prevent access to the storage. The number of failures can be reset in @@ -126,6 +131,15 @@ mount is reset. **Seconds to wait for a storage access attempt:** The time in seconds GitLab will try to access storage. After this time a timeout error will be raised. +To enable the circuitbreaker for repository storage you can flip the feature flag from a rails console: + +``` +Feature.enable('git_storage_circuit_breaker') +``` + +Alternatively it can be enabled by setting `true` in the `GIT_STORAGE_CIRCUIT_BREAKER` environment variable. +This approach would be used when enabling the circuit breaker on a single host. + When storage failures occur, this will be visible in the admin interface like this: ![failing storage](img/failing_storage.png) diff --git a/doc/api/README.md b/doc/api/README.md index de0fe79b3d6..89ffe9d7868 100644 --- a/doc/api/README.md +++ b/doc/api/README.md @@ -37,6 +37,7 @@ following locations: - [Notes](notes.md) (comments) - [Notification settings](notification_settings.md) - [Open source license templates](templates/licenses.md) +- [Pages Domains](pages_domains.md) - [Pipelines](pipelines.md) - [Pipeline Triggers](pipeline_triggers.md) - [Pipeline Schedules](pipeline_schedules.md) @@ -458,7 +459,7 @@ Content-Type: application/json ## Encoding `+` in ISO 8601 dates If you need to include a `+` in a query parameter, you may need to use `%2B` instead due -a [W3 recommendation]((http://www.w3.org/Addressing/URL/4_URI_Recommentations.html) that +a [W3 recommendation](http://www.w3.org/Addressing/URL/4_URI_Recommentations.html) that causes a `+` to be interpreted as a space. For example, in an ISO 8601 date, you may want to pass a time in Mountain Standard Time, such as: diff --git a/doc/api/groups.md b/doc/api/groups.md index c2daa8bc029..99d200c9c93 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -40,6 +40,38 @@ GET /groups ] ``` +When adding the parameter `statistics=true` and the authenticated user is an admin, additional group statistics are returned. + +``` +GET /groups?statistics=true +``` + +```json +[ + { + "id": 1, + "name": "Foobar Group", + "path": "foo-bar", + "description": "An interesting group", + "visibility": "public", + "lfs_enabled": true, + "avatar_url": "http://localhost:3000/uploads/group/avatar/1/foo.jpg", + "web_url": "http://localhost:3000/groups/foo-bar", + "request_access_enabled": false, + "full_name": "Foobar Group", + "full_path": "foo-bar", + "parent_id": null, + "statistics": { + "storage_size" : 212, + "repository_size" : 33, + "lfs_objects_size" : 123, + "job_artifacts_size" : 57 + + } + } +] +``` + You can search for groups by name or path, see below. ## List a group's projects diff --git a/doc/api/pages_domains.md b/doc/api/pages_domains.md new file mode 100644 index 00000000000..51962595e33 --- /dev/null +++ b/doc/api/pages_domains.md @@ -0,0 +1,170 @@ +# Pages domains API + +Endpoints for connecting custom domain(s) and TLS certificates in [GitLab Pages](https://about.gitlab.com/features/pages/). + +The GitLab Pages feature must be enabled to use these endpoints. Find out more about [administering](../administration/pages/index.md) and [using](../user/project/pages/index.md) the feature. + +## List pages domains + +Get a list of project pages domains. The user must have permissions to view pages domains. + +```http +GET /projects/:id/pages/domains +``` + +| Attribute | Type | Required | Description | +| --------- | -------------- | -------- | ---------------------------------------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | + +```bash +curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/5/pages/domains +``` + +```json +[ + { + "domain": "www.domain.example", + "url": "http://www.domain.example" + }, + { + "domain": "ssl.domain.example", + "url": "https://ssl.domain.example", + "certificate": { + "subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate", + "expired": false, + "certificate": "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----", + "certificate_text": "Certificate:\n … \n" + } + } +] +``` + +## Single pages domain + +Get a single project pages domain. The user must have permissions to view pages domains. + +```http +GET /projects/:id/pages/domains/:domain +``` + +| Attribute | Type | Required | Description | +| --------- | -------------- | -------- | ---------------------------------------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `domain` | string | yes | The domain | + +```bash +curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/5/pages/domains/www.domain.example +``` + +```json +{ + "domain": "www.domain.example", + "url": "http://www.domain.example" +} +``` + +```bash +curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example +``` + +```json +{ + "domain": "ssl.domain.example", + "url": "https://ssl.domain.example", + "certificate": { + "subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate", + "expired": false, + "certificate": "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----", + "certificate_text": "Certificate:\n … \n" + } +} +``` + +## Create new pages domain + +Creates a new pages domain. The user must have permissions to create new pages domains. + +```http +POST /projects/:id/pages/domains +``` + +| Attribute | Type | Required | Description | +| ------------- | -------------- | -------- | ---------------------------------------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `domain` | string | yes | The domain | +| `certificate` | file/string | no | The certificate in PEM format with intermediates following in most specific to least specific order.| +| `key` | file/string | no | The certificate key in PEM format. | + +```bash +curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form="domain=ssl.domain.example" --form="certificate=@/path/to/cert.pem" --form="key=@/path/to/key.pem" https://gitlab.example.com/api/v4/projects/5/pages/domains +``` + +```bash +curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form="domain=ssl.domain.example" --form="certificate=$CERT_PEM" --form="key=$KEY_PEM" https://gitlab.example.com/api/v4/projects/5/pages/domains +``` + +```json +{ + "domain": "ssl.domain.example", + "url": "https://ssl.domain.example", + "certificate": { + "subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate", + "expired": false, + "certificate": "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----", + "certificate_text": "Certificate:\n … \n" + } +} +``` + +## Update pages domain + +Updates an existing project pages domain. The user must have permissions to change an existing pages domains. + +```http +PUT /projects/:id/pages/domains/:domain +``` + +| Attribute | Type | Required | Description | +| ------------- | -------------- | -------- | ---------------------------------------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `domain` | string | yes | The domain | +| `certificate` | file/string | no | The certificate in PEM format with intermediates following in most specific to least specific order.| +| `key` | file/string | no | The certificate key in PEM format. | + +```bash +curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form="certificate=@/path/to/cert.pem" --form="key=@/path/to/key.pem" https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example +``` + +```bash +curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form="certificate=$CERT_PEM" --form="key=$KEY_PEM" https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example +``` + +```json +{ + "domain": "ssl.domain.example", + "url": "https://ssl.domain.example", + "certificate": { + "subject": "/O=Example, Inc./OU=Example Origin CA/CN=Example Origin Certificate", + "expired": false, + "certificate": "-----BEGIN CERTIFICATE-----\n … \n-----END CERTIFICATE-----", + "certificate_text": "Certificate:\n … \n" + } +} +``` + +## Delete pages domain + +Deletes an existing project pages domain. + +```http +DELETE /projects/:id/pages/domains/:domain +``` + +| Attribute | Type | Required | Description | +| --------- | -------------- | -------- | ---------------------------------------- | +| `id` | integer/string | yes | The ID or [URL-encoded path of the project](README.md#namespaced-path-encoding) owned by the authenticated user | +| `domain` | string | yes | The domain | + +```bash +curl --request DELETE --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/projects/5/pages/domains/ssl.domain.example +``` diff --git a/doc/api/services.md b/doc/api/services.md index 49b87a4228c..6c8f196fd5c 100644 --- a/doc/api/services.md +++ b/doc/api/services.md @@ -478,8 +478,8 @@ PUT /projects/:id/services/jira | --------- | ---- | -------- | ----------- | | `url` | string | yes | The URL to the JIRA project which is being linked to this GitLab project, e.g., `https://jira.example.com`. | | `project_key` | string | yes | The short identifier for your JIRA project, all uppercase, e.g., `PROJ`. | -| `username` | string | no | The username of the user created to be used with GitLab/JIRA. | -| `password` | string | no | The password of the user created to be used with GitLab/JIRA. | +| `username` | string | yes | The username of the user created to be used with GitLab/JIRA. | +| `password` | string | yes | The password of the user created to be used with GitLab/JIRA. | | `jira_issue_transition_id` | integer | no | The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (**Administration > Issues > Workflows**) by selecting **View** under **Operations** of the desired workflow of your project. The ID of each state can be found inside the parenthesis of each transition name under the **Transitions (id)** column ([see screenshot][trans]). By default, this ID is set to `2`. | ### Delete JIRA service diff --git a/doc/api/settings.md b/doc/api/settings.md index 664f3ef7b77..4e24e4bbfc3 100644 --- a/doc/api/settings.md +++ b/doc/api/settings.md @@ -69,6 +69,8 @@ PUT /application/settings | `after_sign_up_text` | string | no | Text shown to the user after signing up | | `akismet_api_key` | string | no | API key for akismet spam protection | | `akismet_enabled` | boolean | no | Enable or disable akismet spam protection | +| `circuitbreaker_access_retries | integer | no | The number of attempts GitLab will make to access a storage. | +| `circuitbreaker_backoff_threshold | integer | no | The number of failures after which GitLab will start temporarily disabling access to a storage shard on a host. | | `circuitbreaker_failure_count_threshold` | integer | no | The number of failures of after which GitLab will completely prevent access to the storage. | | `circuitbreaker_failure_reset_time` | integer | no | Time in seconds GitLab will keep storage failure information. When no failures occur during this time, the failure information is reset. | | `circuitbreaker_failure_wait_time` | integer | no | Time in seconds GitLab will block access to a failing storage to allow it to recover. | diff --git a/doc/ci/docker/using_docker_images.md b/doc/ci/docker/using_docker_images.md index fa823ea4721..f7493794b6a 100644 --- a/doc/ci/docker/using_docker_images.md +++ b/doc/ci/docker/using_docker_images.md @@ -327,10 +327,6 @@ means, that when starting the container without additional options, it will run the database's process, while Runner expects that the image will have no entrypoint or at least will start with a shell as its entrypoint. -Previously we would need to create our own image based on the -`super/sql:experimental` image, set the entrypoint to a shell, and then use -it in job's configuration, e.g.: - Before the new extended Docker configuration options, you would need to create your own image based on the `super/sql:experimental` image, set the entrypoint to a shell and then use it in job's configuration, like: diff --git a/doc/development/ee_features.md b/doc/development/ee_features.md new file mode 100644 index 00000000000..932a44f65e4 --- /dev/null +++ b/doc/development/ee_features.md @@ -0,0 +1,382 @@ +# Guidelines for implementing Enterprise Edition feature + +- **Write the code and the tests.**: As with any code, EE features should have + good test coverage to prevent regressions. +- **Write documentation.**: Add documentation to the `doc/` directory. Describe + the feature and include screenshots, if applicable. +- **Submit a MR to the `www-gitlab-com` project.**: Add the new feature to the + [EE features list][ee-features-list]. + +## Act as CE when unlicensed + +Since the implementation of [GitLab CE features to work with unlicensed EE instance][ee-as-ce] +GitLab Enterprise Edition should work like GitLab Community Edition +when no license is active. So EE features always should be guarded by +`project.feature_available?` or `group.feature_available?` (or +`License.feature_available?` if it is a system-wide feature). + +CE specs should remain untouched as much as possible and extra specs +should be added for EE. Licensed features can be stubbed using the +spec helper `stub_licensed_features` in `EE::LicenseHelpers`. + +[ee-as-ce]: https://gitlab.com/gitlab-org/gitlab-ee/issues/2500 + +## Separation of EE code + +We want a [single code base][] eventually, but before we reach the goal, +we still need to merge changes from GitLab CE to EE. To help us get there, +we should make sure that we no longer edit CE files in place in order to +implement EE features. + +Instead, all EE codes should be put inside the `ee/` top-level directory, and +tests should be put inside `spec/ee/`. We don't use `ee/spec` for now due to +technical limitation. The rest of codes should be as close as to the CE files. + +[single code base]: https://gitlab.com/gitlab-org/gitlab-ee/issues/2952#note_41016454 + +### EE-only features + +If the feature being developed is not present in any form in CE, we don't +need to put the codes under `EE` namespace. For example, an EE model could +go into: `ee/app/models/awesome.rb` using `Awesome` as the class name. This +is applied not only to models. Here's a list of other examples: + +- `ee/app/controllers/foos_controller.rb` +- `ee/app/finders/foos_finder.rb` +- `ee/app/helpers/foos_helper.rb` +- `ee/app/mailers/foos_mailer.rb` +- `ee/app/models/foo.rb` +- `ee/app/policies/foo_policy.rb` +- `ee/app/serializers/foo_entity.rb` +- `ee/app/serializers/foo_serializer.rb` +- `ee/app/services/foo/create_service.rb` +- `ee/app/validators/foo_attr_validator.rb` +- `ee/app/workers/foo_worker.rb` + +### EE features based on CE features + +For features that build on existing CE features, write a module in the +`EE` namespace and `prepend` it in the CE class. This makes conflicts +less likely to happen during CE to EE merges because only one line is +added to the CE class - the `prepend` line. + +Since the module would require an `EE` namespace, the file should also be +put in an `ee/` sub-directory. For example, we want to extend the user model +in EE, so we have a module called `::EE::User` put inside +`ee/app/models/ee/user.rb`. + +This is also not just applied to models. Here's a list of other examples: + +- `ee/app/controllers/ee/foos_controller.rb` +- `ee/app/finders/ee/foos_finder.rb` +- `ee/app/helpers/ee/foos_helper.rb` +- `ee/app/mailers/ee/foos_mailer.rb` +- `ee/app/models/ee/foo.rb` +- `ee/app/policies/ee/foo_policy.rb` +- `ee/app/serializers/ee/foo_entity.rb` +- `ee/app/serializers/ee/foo_serializer.rb` +- `ee/app/services/ee/foo/create_service.rb` +- `ee/app/validators/ee/foo_attr_validator.rb` +- `ee/app/workers/ee/foo_worker.rb` + +#### Overriding CE methods + +To override a method present in the CE codebase, use `prepend`. It +lets you override a method in a class with a method from a module, while +still having access the class's implementation with `super`. + +There are a few gotchas with it: + +- you should always add a `raise NotImplementedError unless defined?(super)` + guard clause in the "overrider" method to ensure that if the method gets + renamed in CE, the EE override won't be silently forgotten. +- when the "overrider" would add a line in the middle of the CE + implementation, you should refactor the CE method and split it in + smaller methods. Or create a "hook" method that is empty in CE, + and with the EE-specific implementation in EE. +- when the original implementation contains a guard clause (e.g. + `return unless condition`), we cannot easily extend the behaviour by + overriding the method, because we can't know when the overridden method + (i.e. calling `super` in the overriding method) would want to stop early. + In this case, we shouldn't just override it, but update the original method + to make it call the other method we want to extend, like a [template method + pattern](https://en.wikipedia.org/wiki/Template_method_pattern). + For example, given this base: + ``` ruby + class Base + def execute + return unless enabled? + + # ... + # ... + end + end + ``` + Instead of just overriding `Base#execute`, we should update it and extract + the behaviour into another method: + ``` ruby + class Base + def execute + return unless enabled? + + do_something + end + + private + + def do_something + # ... + # ... + end + end + ``` + Then we're free to override that `do_something` without worrying about the + guards: + ``` ruby + module EE::Base + def do_something + # Follow the above pattern to call super and extend it + end + end + ``` + This would require updating CE first, or make sure this is back ported to CE. + +When prepending, place them in the `ee/` specific sub-directory, and +wrap class or module in `module EE` to avoid naming conflicts. + +For example to override the CE implementation of +`ApplicationController#after_sign_out_path_for`: + +```ruby +def after_sign_out_path_for(resource) + current_application_settings.after_sign_out_path.presence || new_user_session_path +end +``` + +Instead of modifying the method in place, you should add `prepend` to +the existing file: + +```ruby +class ApplicationController < ActionController::Base + prepend EE::ApplicationController + # ... + + def after_sign_out_path_for(resource) + current_application_settings.after_sign_out_path.presence || new_user_session_path + end + + # ... +end +``` + +And create a new file in the `ee/` sub-directory with the altered +implementation: + +```ruby +module EE + class ApplicationController + def after_sign_out_path_for(resource) + raise NotImplementedError unless defined?(super) + + if Gitlab::Geo.secondary? + Gitlab::Geo.primary_node.oauth_logout_url(@geo_logout_state) + else + super + end + end + end +end +``` + +#### Use self-descriptive wrapper methods + +When it's not possible/logical to modify the implementation of a +method. Wrap it in a self-descriptive method and use that method. + +For example, in CE only an `admin` is allowed to access all private +projects/groups, but in EE also an `auditor` has full private +access. It would be incorrect to override the implementation of +`User#admin?`, so instead add a method `full_private_access?` to +`app/models/users.rb`. The implementation in CE will be: + +```ruby +def full_private_access? + admin? +end +``` + +In EE, the implementation `ee/app/models/ee/users.rb` would be: + +```ruby +def full_private_access? + raise NotImplementedError unless defined?(super) + super || auditor? +end +``` + +In `lib/gitlab/visibility_level.rb` this method is used to return the +allowed visibilty levels: + +```ruby +def levels_for_user(user = nil) + if user.full_private_access? + [PRIVATE, INTERNAL, PUBLIC] + elsif # ... +end +``` + +See [CE MR][ce-mr-full-private] and [EE MR][ee-mr-full-private] for +full implementation details. + +[ce-mr-full-private]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12373 +[ee-mr-full-private]: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2199 + +### Code in `app/controllers/` + +In controllers, the most common type of conflict is with `before_action` that +has a list of actions in CE but EE adds some actions to that list. + +The same problem often occurs for `params.require` / `params.permit` calls. + +**Mitigations** + +Separate CE and EE actions/keywords. For instance for `params.require` in +`ProjectsController`: + +```ruby +def project_params + params.require(:project).permit(project_params_attributes) +end + +# Always returns an array of symbols, created however best fits the use case. +# It _should_ be sorted alphabetically. +def project_params_attributes + %i[ + description + name + path + ] +end + +``` + +In the `EE::ProjectsController` module: + +```ruby +def project_params_attributes + super + project_params_attributes_ee +end + +def project_params_attributes_ee + %i[ + approvals_before_merge + approver_group_ids + approver_ids + ... + ] +end +``` + +### Code in `app/models/` + +EE-specific models should `extend EE::Model`. + +For example, if EE has a specific `Tanuki` model, you would +place it in `ee/app/models/ee/tanuki.rb`. + +### Code in `app/views/` + +It's a very frequent problem that EE is adding some specific view code in a CE +view. For instance the approval code in the project's settings page. + +**Mitigations** + +Blocks of code that are EE-specific should be moved to partials. This +avoids conflicts with big chunks of HAML code that that are not fun to +resolve when you add the indentation to the equation. + +EE-specific views should be placed in `ee/app/views/ee/`, using extra +sub-directories if appropriate. + +### Code in `lib/` + +Place EE-specific logic in the top-level `EE` module namespace. Namespace the +class beneath the `EE` module just as you would normally. + +For example, if CE has LDAP classes in `lib/gitlab/ldap/` then you would place +EE-specific LDAP classes in `ee/lib/ee/gitlab/ldap`. + +### Code in `spec/` + +When you're testing EE-only features, avoid adding examples to the +existing CE specs. Also do no change existing CE examples, since they +should remain working as-is when EE is running without a license. + +Instead place EE specs in the `spec/ee/spec` folder. + +## JavaScript code in `assets/javascripts/` + +To separate EE-specific JS-files we can also move the files into an `ee` folder. + +For example there can be an +`app/assets/javascripts/protected_branches/protected_branches_bundle.js` and an +EE counterpart +`ee/app/assets/javascripts/protected_branches/protected_branches_bundle.js`. + +That way we can create a separate webpack bundle in `webpack.config.js`: + +```javascript + protected_branches: '~/protected_branches', + ee_protected_branches: 'ee/protected_branches/protected_branches_bundle.js', +``` + +With the separate bundle in place, we can decide which bundle to load inside the +view, using the `page_specific_javascript_bundle_tag` helper. + +```haml +- content_for :page_specific_javascripts do + = page_specific_javascript_bundle_tag('protected_branches') +``` + +## SCSS code in `assets/stylesheets` + +To separate EE-specific styles in SCSS files, if a component you're adding styles for +is limited to only EE, it is better to have a separate SCSS file in appropriate directory +within `app/assets/stylesheets`. + +In some cases, this is not entirely possible or creating dedicated SCSS file is an overkill, +e.g. a text style of some component is different for EE. In such cases, +styles are usually kept in stylesheet that is common for both CE and EE, and it is wise +to isolate such ruleset from rest of CE rules (along with adding comment describing the same) +to avoid conflicts during CE to EE merge. + +#### Bad +```scss +.section-body { + .section-title { + background: $gl-header-color; + } + + &.ee-section-body { + .section-title { + background: $gl-header-color-cyan; + } + } +} +``` + +#### Good +```scss +.section-body { + .section-title { + background: $gl-header-color; + } +} + +/* EE-specific styles */ +.section-body.ee-section-body { + .section-title { + background: $gl-header-color-cyan; + } +} +``` diff --git a/doc/development/fe_guide/index.md b/doc/development/fe_guide/index.md index c0e1bfc12a1..73366eb9f3f 100644 --- a/doc/development/fe_guide/index.md +++ b/doc/development/fe_guide/index.md @@ -71,6 +71,9 @@ Vue specific design patterns and practices. --- +## [Vue Resource](vue_resource.md) +Vue resource specific practices and gotchas. + ## [Icons](icons.md) How we use SVG for our Icons. diff --git a/doc/development/fe_guide/vue.md b/doc/development/fe_guide/vue.md index 277e0cd5f00..f88f0753687 100644 --- a/doc/development/fe_guide/vue.md +++ b/doc/development/fe_guide/vue.md @@ -179,6 +179,7 @@ itself, please read this guide: [State Management][state-management] The Service is a class used only to communicate with the server. It does not store or manipulate any data. It is not aware of the store or the components. We use [vue-resource][vue-resource-repo] to communicate with the server. +Refer to [vue resource](vue_resource.md) for more details. Vue Resource should only be imported in the service file. @@ -189,55 +190,6 @@ Vue Resource should only be imported in the service file. Vue.use(VueResource); ``` -#### Vue-resource gotchas -#### Headers -Headers are being parsed into a plain object in an interceptor. -In Vue-resource 1.x `headers` object was changed into an `Headers` object. In order to not change all old code, an interceptor was added. - -If you need to write a unit test that takes the headers in consideration, you need to include an interceptor to parse the headers after your test interceptor. -You can see an example in `spec/javascripts/environments/environment_spec.js`: - ```javascript - import { headersInterceptor } from './helpers/vue_resource_helper'; - - beforeEach(() => { - Vue.http.interceptors.push(myInterceptor); - Vue.http.interceptors.push(headersInterceptor); - }); - - afterEach(() => { - Vue.http.interceptors = _.without(Vue.http.interceptors, myInterceptor); - Vue.http.interceptors = _.without(Vue.http.interceptors, headersInterceptor); - }); - ``` - -#### `.json()` -When making a request to the server, you will most likely need to access the body of the response. -Use `.json()` to convert. Because `.json()` returns a Promise the follwoing structure should be used: - - ```javascript - service.get('url') - .then(resp => resp.json()) - .then((data) => { - this.store.storeData(data); - }) - .catch(() => new Flash('Something went wrong')); - ``` - -When using `Poll` (`app/assets/javascripts/lib/utils/poll.js`), the `successCallback` needs to handle `.json()` as a Promise: - ```javascript - successCallback: (response) => { - return response.json().then((data) => { - // handle the response - }); - } - ``` - -#### CSRF token -We use a Vue Resource interceptor to manage the CSRF token. -`app/assets/javascripts/vue_shared/vue_resource_interceptor.js` holds all our common interceptors. -Note: You don't need to load `app/assets/javascripts/vue_shared/vue_resource_interceptor.js` -since it's already being loaded by `common_vue.js`. - ### End Result The following example shows an application: @@ -769,7 +721,6 @@ describe('component', () => { [component-system]: https://vuejs.org/v2/guide/#Composing-with-Components [state-management]: https://vuejs.org/v2/guide/state-management.html#Simple-State-Management-from-Scratch [one-way-data-flow]: https://vuejs.org/v2/guide/components.html#One-Way-Data-Flow -[vue-resource-repo]: https://github.com/pagekit/vue-resource [vue-resource-interceptor]: https://github.com/pagekit/vue-resource/blob/develop/docs/http.md#interceptors [vue-test]: https://vuejs.org/v2/guide/unit-testing.html [issue-boards-service]: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/assets/javascripts/boards/services/board_service.js.es6 diff --git a/doc/development/fe_guide/vue_resource.md b/doc/development/fe_guide/vue_resource.md new file mode 100644 index 00000000000..c376c5c32bf --- /dev/null +++ b/doc/development/fe_guide/vue_resource.md @@ -0,0 +1,72 @@ +# Vue Resouce +In Vue applications we use [vue-resource][vue-resource-repo] to communicate with the server. + +## HTTP Status Codes + +### `.json()` +When making a request to the server, you will most likely need to access the body of the response. +Use `.json()` to convert. Because `.json()` returns a Promise the follwoing structure should be used: + + ```javascript + service.get('url') + .then(resp => resp.json()) + .then((data) => { + this.store.storeData(data); + }) + .catch(() => new Flash('Something went wrong')); + ``` + + +When using `Poll` (`app/assets/javascripts/lib/utils/poll.js`), the `successCallback` needs to handle `.json()` as a Promise: + ```javascript + successCallback: (response) => { + return response.json().then((data) => { + // handle the response + }); + } + ``` + +### 204 +Some endpoints - usually `delete` endpoints - return `204` as the success response. +When handling `204 - No Content` responses, we cannot use `.json()` since it tries to parse the non-existant body content. + +When handling `204` responses, do not use `.json`, otherwise the promise will throw an error and will enter the `catch` statement: + +```javascript + Vue.http.delete('path') + .then(() => { + // success! + }) + .catch(() => { + // handle error + }) +``` + +## Headers +Headers are being parsed into a plain object in an interceptor. +In Vue-resource 1.x `headers` object was changed into an `Headers` object. In order to not change all old code, an interceptor was added. + +If you need to write a unit test that takes the headers in consideration, you need to include an interceptor to parse the headers after your test interceptor. +You can see an example in `spec/javascripts/environments/environment_spec.js`: + ```javascript + import { headersInterceptor } from './helpers/vue_resource_helper'; + + beforeEach(() => { + Vue.http.interceptors.push(myInterceptor); + Vue.http.interceptors.push(headersInterceptor); + }); + + afterEach(() => { + Vue.http.interceptors = _.without(Vue.http.interceptors, myInterceptor); + Vue.http.interceptors = _.without(Vue.http.interceptors, headersInterceptor); + }); + ``` + +## CSRF token +We use a Vue Resource interceptor to manage the CSRF token. +`app/assets/javascripts/vue_shared/vue_resource_interceptor.js` holds all our common interceptors. +Note: You don't need to load `app/assets/javascripts/vue_shared/vue_resource_interceptor.js` +since it's already being loaded by `common_vue.js`. + + +[vue-resource-repo]: https://github.com/pagekit/vue-resource diff --git a/doc/gitlab-basics/add-merge-request.md b/doc/gitlab-basics/add-merge-request.md index bf01fe51dc3..5cc014419ad 100644 --- a/doc/gitlab-basics/add-merge-request.md +++ b/doc/gitlab-basics/add-merge-request.md @@ -3,31 +3,28 @@ Merge requests are useful to integrate separate changes that you've made to a project, on different branches. This is a brief guide on how to create a merge request. For more information, check the -[merge requests documentation](../user/project/merge_requests.md). +[merge requests documentation](../user/project/merge_requests/index.md). --- 1. Before you start, you should have already [created a branch](create-branch.md) and [pushed your changes](basic-git-commands.md) to GitLab. - -1. You can then go to the project where you'd like to merge your changes and - click on the **Merge requests** tab. - - ![Merge requests](img/project_navbar.png) - +1. Go to the project where you'd like to merge your changes and click on the + **Merge requests** tab. 1. Click on **New merge request** on the right side of the screen. - - ![New Merge Request](img/merge_request_new.png) - -1. Select a source branch and click on the **Compare branches and continue** button. +1. From there on, you have the option to select the source branch and the target + branch you'd like to compare to. The default target project is the upstream + repository, but you can choose to compare across any of its forks. ![Select a branch](img/merge_request_select_branch.png) +1. When ready, click on the **Compare branches and continue** button. 1. At a minimum, add a title and a description to your merge request. Optionally, select a user to review your merge request and to accept or close it. You may also select a milestone and labels. ![New merge request page](img/merge_request_page.png) -1. When ready, click on the **Submit merge request** button. Your merge request - will be ready to be approved and published. +1. When ready, click on the **Submit merge request** button. + +Your merge request will be ready to be approved and merged. diff --git a/doc/gitlab-basics/img/merge_request_new.png b/doc/gitlab-basics/img/merge_request_new.png deleted file mode 100644 index 6fcd7bebada..00000000000 Binary files a/doc/gitlab-basics/img/merge_request_new.png and /dev/null differ diff --git a/doc/gitlab-basics/img/merge_request_select_branch.png b/doc/gitlab-basics/img/merge_request_select_branch.png index 9f6b93943a9..57ea0e65f34 100644 Binary files a/doc/gitlab-basics/img/merge_request_select_branch.png and b/doc/gitlab-basics/img/merge_request_select_branch.png differ diff --git a/doc/gitlab-basics/img/project_navbar.png b/doc/gitlab-basics/img/project_navbar.png deleted file mode 100644 index be6f38ede32..00000000000 Binary files a/doc/gitlab-basics/img/project_navbar.png and /dev/null differ diff --git a/doc/integration/saml.md b/doc/integration/saml.md index b5b245c626f..3ae98adc465 100644 --- a/doc/integration/saml.md +++ b/doc/integration/saml.md @@ -132,14 +132,17 @@ On the sign in page there should now be a SAML button below the regular sign in Click the icon to begin the authentication process. If everything goes well the user will be returned to GitLab and will be signed in. -## External Groups +## Marking Users as External based on SAML Groups >**Note:** This setting is only available on GitLab 8.7 and above. -SAML login includes support for external groups. You can define in the SAML -settings which groups, to which your users belong in your IdP, you wish to be -marked as [external](../user/permissions.md). +SAML login includes support for automatically identifying whether a user should +be considered an [external](../user/permissions.md) user based on the user's group +membership in the SAML identity provider. This feature **does not** allow you to +automatically add users to GitLab [Groups](../user/group/index.md), it simply +allows you to mark users as External if they are members of certain groups in the +Identity Provider. ### Requirements diff --git a/doc/integration/trello_power_up.md b/doc/integration/trello_power_up.md index d264486a872..834d63d1166 100644 --- a/doc/integration/trello_power_up.md +++ b/doc/integration/trello_power_up.md @@ -39,4 +39,4 @@ Learn more about generating a personal access token in the [Personal Access Token Documentation][personal-access-token-documentation]. Don't forget to check the API scope checkbox! -[personal-access-token-documentation]: ../user/profile/personal_access_tokens.html +[personal-access-token-documentation]: ../user/profile/personal_access_tokens.md diff --git a/doc/user/project/import/index.md b/doc/user/project/import/index.md index 8da6e2a8207..e2b285678c3 100644 --- a/doc/user/project/import/index.md +++ b/doc/user/project/import/index.md @@ -4,7 +4,7 @@ 1. [From ClearCase](clearcase.md) 1. [From CVS](cvs.md) 1. [From FogBugz](fogbugz.md) -1. [From GitHub.com of GitHub Enterprise](github.md) +1. [From GitHub.com or GitHub Enterprise](github.md) 1. [From GitLab.com](gitlab_com.md) 1. [From Gitea](gitea.md) 1. [From Perforce](perforce.md) diff --git a/doc/user/project/merge_requests/index.md b/doc/user/project/merge_requests/index.md index 6289fcf3c2b..4b2e042251b 100644 --- a/doc/user/project/merge_requests/index.md +++ b/doc/user/project/merge_requests/index.md @@ -34,7 +34,6 @@ With **[GitLab Enterprise Edition][ee]**, you can also: - View the deployment process across projects with [Multi-Project Pipeline Graphs](https://docs.gitlab.com/ee/ci/multi_project_pipeline_graphs.html#multi-project-pipeline-graphs) (available only in GitLab Enterprise Edition Premium) - Request [approvals](https://docs.gitlab.com/ee/user/project/merge_requests/merge_request_approvals.html) from your managers (available in GitLab Enterprise Edition Starter) - [Squash and merge](https://docs.gitlab.com/ee/user/project/merge_requests/squash_and_merge.html) for a cleaner commit history (available in GitLab Enterprise Edition Starter) -- Enable [semi-linear history merge requests](https://docs.gitlab.com/ee/user/project/merge_requests/index.html#semi-linear-history-merge-requests) as another security layer to guarantee the pipeline is passing in the target branch (available in GitLab Enterprise Edition Starter) - Analise the impact of your changes with [Code Quality reports](https://docs.gitlab.com/ee/user/project/merge_requests/code_quality_diff.html) (available in GitLab Enterprise Edition Starter) ## Use cases diff --git a/doc/user/project/pages/introduction.md b/doc/user/project/pages/introduction.md index 4fcdfa7b281..3ab88948fbd 100644 --- a/doc/user/project/pages/introduction.md +++ b/doc/user/project/pages/introduction.md @@ -3,7 +3,7 @@ > **Notes:** > - This feature was [introduced][ee-80] in GitLab EE 8.3. > - Custom CNAMEs with TLS support were [introduced][ee-173] in GitLab EE 8.5. -> - GitLab Pages [were ported][ce-14605] to Community Edition in GitLab 8.17. +> - GitLab Pages [was ported][ce-14605] to Community Edition in GitLab 8.17. > - This document is about the user guide. To learn how to enable GitLab Pages > across your GitLab instance, visit the [administrator documentation](../../../administration/pages/index.md). @@ -174,7 +174,7 @@ job, the contents of the `public` directory will be served by GitLab Pages. #### How `.gitlab-ci.yml` looks like when the static content is in your repository -Supposedly your repository contained the following files: +Supposed your repository contained the following files: ``` ├── index.html @@ -419,7 +419,7 @@ You can only create the highest level group website. ## Redirects in GitLab Pages Since you cannot use any custom server configuration files, like `.htaccess` or -any `.conf` file for that matter, if you want to redirect a web page to another +any `.conf` file, if you want to redirect a page to another location, you can use the [HTTP meta refresh tag][metarefresh]. Some static site generators provide plugins for that functionality so that you @@ -434,7 +434,7 @@ Sure. All you need to do is download the artifacts archive from the job page. ### Can I use GitLab Pages if my project is private? -Yes. GitLab Pages don't care whether you set your project's visibility level +Yes. GitLab Pages doesn't care whether you set your project's visibility level to private, internal or public. ### Do I need to create a user/group website before creating a project website? diff --git a/doc/user/project/repository/branches/index.md b/doc/user/project/repository/branches/index.md index e1d3aebb8b3..26c55891b3c 100644 --- a/doc/user/project/repository/branches/index.md +++ b/doc/user/project/repository/branches/index.md @@ -37,7 +37,7 @@ This feature allows merged branches to be deleted in bulk. Only branches that have been merged and [are not protected][protected] will be deleted as part of this operation. -It's particularly useful to clean up old branches that were not deleting +It's particularly useful to clean up old branches that were not deleted automatically when a merge request was merged. [ce-6449]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6449 "Add button to delete all merged branches" diff --git a/doc/user/project/repository/web_editor.md b/doc/user/project/repository/web_editor.md index d47a3acdbe9..db0c3ed9d59 100644 --- a/doc/user/project/repository/web_editor.md +++ b/doc/user/project/repository/web_editor.md @@ -105,7 +105,7 @@ merge request. Once you click it, a new branch will be created that diverges from the default branch of your project, by default `master`. The branch name will be based on -the title of the issue and as suffix it will have its ID. Thus, the example +the title of the issue and as a prefix, it will have its internal ID. Thus, the example screenshot above will yield a branch named `2-et-cum-et-sed-expedita-repellat-consequatur-ut-assumenda-numquam-rerum`. diff --git a/lib/api/api.rb b/lib/api/api.rb index 99fcc59ba04..7db18e25a5f 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -131,6 +131,7 @@ module API mount ::API::Namespaces mount ::API::Notes mount ::API::NotificationSettings + mount ::API::PagesDomains mount ::API::Pipelines mount ::API::PipelineSchedules mount ::API::ProjectHooks diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 5f0bad14839..efe874b2e6b 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1043,5 +1043,22 @@ module API expose :key expose :value end + + class PagesDomainCertificate < Grape::Entity + expose :subject + expose :expired?, as: :expired + expose :certificate + expose :certificate_text + end + + class PagesDomain < Grape::Entity + expose :domain + expose :url + expose :certificate, + if: ->(pages_domain, _) { pages_domain.certificate? }, + using: PagesDomainCertificate do |pages_domain| + pages_domain + end + end end end diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 2b316b58ed9..7a2ec865860 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -184,6 +184,10 @@ module API end end + def require_pages_enabled! + not_found! unless user_project.pages_available? + end + def can?(object, action, subject = :global) Ability.allowed?(object, action, subject) end diff --git a/lib/api/pages_domains.rb b/lib/api/pages_domains.rb new file mode 100644 index 00000000000..259f3f34068 --- /dev/null +++ b/lib/api/pages_domains.rb @@ -0,0 +1,117 @@ +module API + class PagesDomains < Grape::API + include PaginationParams + + before do + authenticate! + require_pages_enabled! + end + + after_validation do + normalize_params_file_to_string + end + + helpers do + def find_pages_domain! + user_project.pages_domains.find_by(domain: params[:domain]) || not_found!('PagesDomain') + end + + def pages_domain + @pages_domain ||= find_pages_domain! + end + + def normalize_params_file_to_string + params.each do |k, v| + if v.is_a?(Hash) && v.key?(:tempfile) + params[k] = v[:tempfile].to_a.join('') + end + end + end + end + + params do + requires :id, type: String, desc: 'The ID of a project' + end + resource :projects, requirements: { id: %r{[^/]+} } do + desc 'Get all pages domains' do + success Entities::PagesDomain + end + params do + use :pagination + end + get ":id/pages/domains" do + authorize! :read_pages, user_project + + present paginate(user_project.pages_domains.order(:domain)), with: Entities::PagesDomain + end + + desc 'Get a single pages domain' do + success Entities::PagesDomain + end + params do + requires :domain, type: String, desc: 'The domain' + end + get ":id/pages/domains/:domain", requirements: { domain: %r{[^/]+} } do + authorize! :read_pages, user_project + + present pages_domain, with: Entities::PagesDomain + end + + desc 'Create a new pages domain' do + success Entities::PagesDomain + end + params do + requires :domain, type: String, desc: 'The domain' + optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate' + optional :key, allow_blank: false, types: [File, String], desc: 'The key' + all_or_none_of :certificate, :key + end + post ":id/pages/domains" do + authorize! :update_pages, user_project + + pages_domain_params = declared(params, include_parent_namespaces: false) + pages_domain = user_project.pages_domains.create(pages_domain_params) + + if pages_domain.persisted? + present pages_domain, with: Entities::PagesDomain + else + render_validation_error!(pages_domain) + end + end + + desc 'Updates a pages domain' + params do + requires :domain, type: String, desc: 'The domain' + optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate' + optional :key, allow_blank: false, types: [File, String], desc: 'The key' + end + put ":id/pages/domains/:domain", requirements: { domain: %r{[^/]+} } do + authorize! :update_pages, user_project + + pages_domain_params = declared(params, include_parent_namespaces: false) + + # Remove empty private key if certificate is not empty. + if pages_domain_params[:certificate] && !pages_domain_params[:key] + pages_domain_params.delete(:key) + end + + if pages_domain.update(pages_domain_params) + present pages_domain, with: Entities::PagesDomain + else + render_validation_error!(pages_domain) + end + end + + desc 'Delete a pages domain' + params do + requires :domain, type: String, desc: 'The domain' + end + delete ":id/pages/domains/:domain", requirements: { domain: %r{[^/]+} } do + authorize! :update_pages, user_project + + status 204 + pages_domain.destroy + end + end + end +end diff --git a/lib/api/services.rb b/lib/api/services.rb index 2cbd0517dc3..1e4f7c29633 100644 --- a/lib/api/services.rb +++ b/lib/api/services.rb @@ -313,13 +313,13 @@ module API desc: 'The base URL to the JIRA instance API. Web URL value will be used if not set. E.g., https://jira-api.example.com' }, { - required: false, + required: true, name: :username, type: String, desc: 'The username of the user created to be used with GitLab/JIRA' }, { - required: false, + required: true, name: :password, type: String, desc: 'The password of the user created to be used with GitLab/JIRA' diff --git a/lib/gitlab/git/branch.rb b/lib/gitlab/git/branch.rb index c53882787f1..3487e099381 100644 --- a/lib/gitlab/git/branch.rb +++ b/lib/gitlab/git/branch.rb @@ -3,6 +3,14 @@ module Gitlab module Git class Branch < Ref + def self.find(repo, branch_name) + if branch_name.is_a?(Gitlab::Git::Branch) + branch_name + else + repo.find_branch(branch_name) + end + end + def initialize(repository, name, target, target_commit) super(repository, name, target, target_commit) end diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb index 1957c254c28..23ae37ff71e 100644 --- a/lib/gitlab/git/commit.rb +++ b/lib/gitlab/git/commit.rb @@ -72,7 +72,8 @@ module Gitlab decorate(repo, commit) if commit rescue Rugged::ReferenceError, Rugged::InvalidError, Rugged::ObjectError, - Gitlab::Git::CommandError, Gitlab::Git::Repository::NoRepository + Gitlab::Git::CommandError, Gitlab::Git::Repository::NoRepository, + Rugged::OdbError, Rugged::TreeError nil end diff --git a/lib/gitlab/git/hooks_service.rb b/lib/gitlab/git/hooks_service.rb index c327e9b1616..f302b852b35 100644 --- a/lib/gitlab/git/hooks_service.rb +++ b/lib/gitlab/git/hooks_service.rb @@ -8,7 +8,7 @@ module Gitlab def execute(pusher, repository, oldrev, newrev, ref) @repository = repository @gl_id = pusher.gl_id - @gl_username = pusher.name + @gl_username = pusher.username @oldrev = oldrev @newrev = newrev @ref = ref diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb index 59a54b48ed9..fc8af38d4d9 100644 --- a/lib/gitlab/git/repository.rb +++ b/lib/gitlab/git/repository.rb @@ -166,7 +166,7 @@ module Gitlab end def local_branches(sort_by: nil) - gitaly_migrate(:local_branches) do |is_enabled| + gitaly_migrate(:local_branches, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT) do |is_enabled| if is_enabled gitaly_ref_client.local_branches(sort_by: sort_by) else @@ -511,6 +511,10 @@ module Gitlab gitaly_commit_client.ancestor?(from, to) end + def merged_branch_names(branch_names = []) + Set.new(git_merged_branch_names(branch_names)) + end + # Return an array of Diff objects that represent the diff # between +from+ and +to+. See Diff::filter_diff_options for the allowed # diff options. The +options+ hash can also include :break_rewrites to @@ -745,6 +749,16 @@ module Gitlab nil end + def ff_merge(user, source_sha, target_branch) + OperationService.new(user, self).with_branch(target_branch) do |our_commit| + raise ArgumentError, 'Invalid merge target' unless our_commit + + source_sha + end + rescue Rugged::ReferenceError + raise ArgumentError, 'Invalid merge source' + end + def revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:) OperationService.new(user, self).with_branch( branch_name, @@ -1180,6 +1194,13 @@ module Gitlab sort_branches(branches, sort_by) end + def git_merged_branch_names(branch_names = []) + lines = run_git(['branch', '--merged', root_ref] + branch_names) + .first.lines + + lines.map(&:strip) + end + def log_using_shell?(options) options[:path].present? || options[:disable_walk] || diff --git a/lib/gitlab/git/storage.rb b/lib/gitlab/git/storage.rb index 08e6c29abad..99518c9b1e4 100644 --- a/lib/gitlab/git/storage.rb +++ b/lib/gitlab/git/storage.rb @@ -12,6 +12,7 @@ module Gitlab CircuitOpen = Class.new(Inaccessible) Misconfiguration = Class.new(Inaccessible) + Failing = Class.new(Inaccessible) REDIS_KEY_PREFIX = 'storage_accessible:'.freeze diff --git a/lib/gitlab/git/storage/circuit_breaker.rb b/lib/gitlab/git/storage/circuit_breaker.rb index 0456ad9a1f3..be7598ef011 100644 --- a/lib/gitlab/git/storage/circuit_breaker.rb +++ b/lib/gitlab/git/storage/circuit_breaker.rb @@ -54,7 +54,7 @@ module Gitlab end def perform - return yield unless Feature.enabled?('git_storage_circuit_breaker') + return yield unless enabled? check_storage_accessible! @@ -64,10 +64,27 @@ module Gitlab def circuit_broken? return false if no_failures? - recent_failure = last_failure > failure_wait_time.seconds.ago - too_many_failures = failure_count > failure_count_threshold + failure_count > failure_count_threshold + end - recent_failure || too_many_failures + def backing_off? + return false if no_failures? + + recent_failure = last_failure > failure_wait_time.seconds.ago + too_many_failures = failure_count > backoff_threshold + + recent_failure && too_many_failures + end + + private + + # The circuitbreaker can be enabled for the entire fleet using a Feature + # flag. + # + # Enabling it for a single host can be done setting the + # `GIT_STORAGE_CIRCUIT_BREAKER` environment variable. + def enabled? + ENV['GIT_STORAGE_CIRCUIT_BREAKER'].present? || Feature.enabled?('git_storage_circuit_breaker') end def failure_info @@ -83,7 +100,7 @@ module Gitlab return @storage_available if @storage_available if @storage_available = Gitlab::Git::Storage::ForkedStorageCheck - .storage_available?(storage_path, storage_timeout) + .storage_available?(storage_path, storage_timeout, access_retries) track_storage_accessible else track_storage_inaccessible @@ -94,7 +111,11 @@ module Gitlab def check_storage_accessible! if circuit_broken? - raise Gitlab::Git::Storage::CircuitOpen.new("Circuit for #{storage} is broken", failure_wait_time) + raise Gitlab::Git::Storage::CircuitOpen.new("Circuit for #{storage} is broken", failure_reset_time) + end + + if backing_off? + raise Gitlab::Git::Storage::Failing.new("Backing off access to #{storage}", failure_wait_time) end unless storage_available? @@ -131,12 +152,6 @@ module Gitlab end end - def cache_key - @cache_key ||= "#{Gitlab::Git::Storage::REDIS_KEY_PREFIX}#{storage}:#{hostname}" - end - - private - def get_failure_info last_failure, failure_count = Gitlab::Git::Storage.redis.with do |redis| redis.hmget(cache_key, :last_failure, :failure_count) @@ -146,6 +161,10 @@ module Gitlab FailureInfo.new(last_failure, failure_count.to_i) end + + def cache_key + @cache_key ||= "#{Gitlab::Git::Storage::REDIS_KEY_PREFIX}#{storage}:#{hostname}" + end end end end diff --git a/lib/gitlab/git/storage/circuit_breaker_settings.rb b/lib/gitlab/git/storage/circuit_breaker_settings.rb index d2313fe7c1b..257fe8cd8f0 100644 --- a/lib/gitlab/git/storage/circuit_breaker_settings.rb +++ b/lib/gitlab/git/storage/circuit_breaker_settings.rb @@ -18,6 +18,14 @@ module Gitlab application_settings.circuitbreaker_storage_timeout end + def access_retries + application_settings.circuitbreaker_access_retries + end + + def backoff_threshold + application_settings.circuitbreaker_backoff_threshold + end + private def application_settings diff --git a/lib/gitlab/git/storage/forked_storage_check.rb b/lib/gitlab/git/storage/forked_storage_check.rb index 91d8241f17b..1307f400700 100644 --- a/lib/gitlab/git/storage/forked_storage_check.rb +++ b/lib/gitlab/git/storage/forked_storage_check.rb @@ -4,8 +4,17 @@ module Gitlab module ForkedStorageCheck extend self - def storage_available?(path, timeout_seconds = 5) - status = timeout_check(path, timeout_seconds) + def storage_available?(path, timeout_seconds = 5, retries = 1) + partial_timeout = timeout_seconds / retries + status = timeout_check(path, partial_timeout) + + # If the status check did not succeed the first time, we retry a few + # more times to avoid one-off failures + current_attempts = 1 + while current_attempts < retries && !status.success? + status = timeout_check(path, partial_timeout) + current_attempts += 1 + end status.success? end diff --git a/lib/gitlab/git/storage/null_circuit_breaker.rb b/lib/gitlab/git/storage/null_circuit_breaker.rb index 60c6791a7e4..a12d52d295f 100644 --- a/lib/gitlab/git/storage/null_circuit_breaker.rb +++ b/lib/gitlab/git/storage/null_circuit_breaker.rb @@ -25,6 +25,10 @@ module Gitlab !!@error end + def backing_off? + false + end + def last_failure circuit_broken? ? Time.now : nil end diff --git a/lib/gitlab/git/user.rb b/lib/gitlab/git/user.rb index da74719ae87..e6b61417de1 100644 --- a/lib/gitlab/git/user.rb +++ b/lib/gitlab/git/user.rb @@ -7,9 +7,8 @@ module Gitlab new(gitlab_user.username, gitlab_user.name, gitlab_user.email, Gitlab::GlId.gl_id(gitlab_user)) end - # TODO support the username field in Gitaly https://gitlab.com/gitlab-org/gitaly/issues/628 def self.from_gitaly(gitaly_user) - new('', gitaly_user.name, gitaly_user.email, gitaly_user.gl_id) + new(gitaly_user.gl_username, gitaly_user.name, gitaly_user.email, gitaly_user.gl_id) end def initialize(username, name, email, gl_id) @@ -22,6 +21,10 @@ module Gitlab def ==(other) [username, name, email, gl_id] == [other.username, other.name, other.email, other.gl_id] end + + def to_gitaly + Gitaly::User.new(gl_username: username, gl_id: gl_id, name: name, email: email) + end end end end diff --git a/lib/gitlab/git/wiki.rb b/lib/gitlab/git/wiki.rb index e7b2f52a552..f01d5c96fc8 100644 --- a/lib/gitlab/git/wiki.rb +++ b/lib/gitlab/git/wiki.rb @@ -8,6 +8,7 @@ module Gitlab { name: name, email: email, message: message } end end + PageBlob = Struct.new(:name) def self.default_ref 'master' @@ -80,7 +81,15 @@ module Gitlab end def preview_slug(title, format) - gollum_wiki.preview_page(title, '', format).url_path + # Adapted from gollum gem (Gollum::Wiki#preview_page) to avoid + # using Rugged through a Gollum::Wiki instance + page_class = Gollum::Page + page = page_class.new(nil) + ext = page_class.format_to_ext(format.to_sym) + name = page_class.cname(title) + '.' + ext + blob = PageBlob.new(name) + page.populate(blob) + page.url_path end private diff --git a/lib/gitlab/git/wiki_file.rb b/lib/gitlab/git/wiki_file.rb index 527f2a44dea..84335aca4bc 100644 --- a/lib/gitlab/git/wiki_file.rb +++ b/lib/gitlab/git/wiki_file.rb @@ -1,7 +1,7 @@ module Gitlab module Git class WikiFile - attr_reader :mime_type, :raw_data, :name + attr_reader :mime_type, :raw_data, :name, :path # This class is meant to be serializable so that it can be constructed # by Gitaly and sent over the network to GitLab. @@ -13,6 +13,7 @@ module Gitlab @mime_type = gollum_file.mime_type @raw_data = gollum_file.raw_data @name = gollum_file.name + @path = gollum_file.path end end end diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 42b59c106e2..8998c4b1a83 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -215,10 +215,6 @@ module Gitlab ).exec end - def matching_merge_request?(newrev, branch_name) - Checks::MatchingMergeRequest.new(newrev, branch_name, project).match? - end - def deploy_key actor if deploy_key? end diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 6c1ae19ff11..6868be26758 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -33,6 +33,12 @@ module Gitlab MUTEX = Mutex.new private_constant :MUTEX + class << self + attr_accessor :query_time + end + + self.query_time = 0 + def self.stub(name, storage) MUTEX.synchronize do @stubs ||= {} @@ -83,11 +89,14 @@ module Gitlab # end # def self.call(storage, service, rpc, request) + start = Process.clock_gettime(Process::CLOCK_MONOTONIC) enforce_gitaly_request_limits(:call) kwargs = request_kwargs(storage) kwargs = yield(kwargs) if block_given? stub(service, storage).__send__(rpc, request, kwargs) # rubocop:disable GitlabSecurity/PublicSend + ensure + self.query_time += Process.clock_gettime(Process::CLOCK_MONOTONIC) - start end def self.request_kwargs(storage) diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb index 91f34011f6e..adaf255f24b 100644 --- a/lib/gitlab/gitaly_client/operation_service.rb +++ b/lib/gitlab/gitaly_client/operation_service.rb @@ -10,7 +10,7 @@ module Gitlab request = Gitaly::UserDeleteTagRequest.new( repository: @gitaly_repo, tag_name: GitalyClient.encode(tag_name), - user: Util.gitaly_user(user) + user: Gitlab::Git::User.from_gitlab(user).to_gitaly ) response = GitalyClient.call(@repository.storage, :operation_service, :user_delete_tag, request) @@ -23,7 +23,7 @@ module Gitlab def add_tag(tag_name, user, target, message) request = Gitaly::UserCreateTagRequest.new( repository: @gitaly_repo, - user: Util.gitaly_user(user), + user: Gitlab::Git::User.from_gitlab(user).to_gitaly, tag_name: GitalyClient.encode(tag_name), target_revision: GitalyClient.encode(target), message: GitalyClient.encode(message.to_s) @@ -45,7 +45,7 @@ module Gitlab request = Gitaly::UserCreateBranchRequest.new( repository: @gitaly_repo, branch_name: GitalyClient.encode(branch_name), - user: Util.gitaly_user(user), + user: Gitlab::Git::User.from_gitlab(user).to_gitaly, start_point: GitalyClient.encode(start_point) ) response = GitalyClient.call(@repository.storage, :operation_service, @@ -65,7 +65,7 @@ module Gitlab request = Gitaly::UserDeleteBranchRequest.new( repository: @gitaly_repo, branch_name: GitalyClient.encode(branch_name), - user: Util.gitaly_user(user) + user: Gitlab::Git::User.from_gitlab(user).to_gitaly ) response = GitalyClient.call(@repository.storage, :operation_service, :user_delete_branch, request) @@ -87,7 +87,7 @@ module Gitlab request_enum.push( Gitaly::UserMergeBranchRequest.new( repository: @gitaly_repo, - user: Util.gitaly_user(user), + user: Gitlab::Git::User.from_gitlab(user).to_gitaly, commit_id: source_sha, branch: GitalyClient.encode(target_branch), message: GitalyClient.encode(message) diff --git a/lib/gitlab/gitaly_client/util.rb b/lib/gitlab/gitaly_client/util.rb index a1222a7e718..b1a033280b4 100644 --- a/lib/gitlab/gitaly_client/util.rb +++ b/lib/gitlab/gitaly_client/util.rb @@ -18,16 +18,6 @@ module Gitlab ) end - def gitaly_user(gitlab_user) - return unless gitlab_user - - Gitaly::User.new( - gl_id: Gitlab::GlId.gl_id(gitlab_user), - name: GitalyClient.encode(gitlab_user.name), - email: GitalyClient.encode(gitlab_user.email) - ) - end - def gitlab_tag_from_gitaly_tag(repository, gitaly_tag) if gitaly_tag.target_commit.present? commit = Gitlab::Git::Commit.decorate(repository, gitaly_tag.target_commit) diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb index 6bffd410ed0..a42e312b5d3 100644 --- a/lib/gitlab/logger.rb +++ b/lib/gitlab/logger.rb @@ -13,7 +13,7 @@ module Gitlab end def self.read_latest - path = Rails.root.join("log", file_name) + path = self.full_log_path return [] unless File.readable?(path) @@ -22,7 +22,15 @@ module Gitlab end def self.build - new(Rails.root.join("log", file_name)) + RequestStore[self.cache_key] ||= new(self.full_log_path) + end + + def self.full_log_path + Rails.root.join("log", file_name) + end + + def self.cache_key + 'logger:'.freeze + self.full_log_path.to_s end end end diff --git a/lib/gitlab/performance_bar/peek_query_tracker.rb b/lib/gitlab/performance_bar/peek_query_tracker.rb index 67fee8c227d..69e117f1da9 100644 --- a/lib/gitlab/performance_bar/peek_query_tracker.rb +++ b/lib/gitlab/performance_bar/peek_query_tracker.rb @@ -36,8 +36,8 @@ module Gitlab end def track_query(raw_query, bindings, start, finish) - query = Gitlab::Sherlock::Query.new(raw_query, start, finish) - query_info = { duration: query.duration.round(3), sql: query.formatted_query } + duration = finish - start + query_info = { duration: duration.round(3), sql: raw_query } PEEK_DB_CLIENT.query_details << query_info end diff --git a/lib/omni_auth/strategies/bitbucket.rb b/lib/omni_auth/strategies/bitbucket.rb index 5a7d67c2390..ce1bdfe6ee4 100644 --- a/lib/omni_auth/strategies/bitbucket.rb +++ b/lib/omni_auth/strategies/bitbucket.rb @@ -36,6 +36,10 @@ module OmniAuth email_response = access_token.get('api/2.0/user/emails').parsed @emails ||= email_response && email_response['values'] || nil end + + def callback_url + options[:redirect_uri] || (full_host + script_name + callback_path) + end end end end diff --git a/lib/peek/views/gitaly.rb b/lib/peek/views/gitaly.rb new file mode 100644 index 00000000000..d519d8e86fa --- /dev/null +++ b/lib/peek/views/gitaly.rb @@ -0,0 +1,34 @@ +module Peek + module Views + class Gitaly < View + def duration + ::Gitlab::GitalyClient.query_time + end + + def calls + ::Gitlab::GitalyClient.get_request_count + end + + def results + { duration: formatted_duration, calls: calls } + end + + private + + def formatted_duration + ms = duration * 1000 + if ms >= 1000 + "%.2fms" % ms + else + "%.0fms" % ms + end + end + + def setup_subscribers + subscribe 'start_processing.action_controller' do + ::Gitlab::GitalyClient.query_time = 0 + end + end + end + end +end diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 1f356a231b0..08f6212d997 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -8,8 +8,8 @@ msgid "" msgstr "" "Project-Id-Version: gitlab 1.0.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-10-10 17:50+0200\n" -"PO-Revision-Date: 2017-10-10 17:50+0200\n" +"POT-Creation-Date: 2017-10-22 16:40+0300\n" +"PO-Revision-Date: 2017-10-22 16:40+0300\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -106,6 +106,12 @@ msgstr "" msgid "Add new directory" msgstr "" +msgid "AdminHealthPageLink|health page" +msgstr "" + +msgid "Advanced settings" +msgstr "" + msgid "All" msgstr "" @@ -127,6 +133,9 @@ msgstr "" msgid "Are you sure you want to discard your changes?" msgstr "" +msgid "Are you sure you want to leave this group?" +msgstr "" + msgid "Are you sure you want to reset registration token?" msgstr "" @@ -160,18 +169,21 @@ msgstr "" msgid "AutoDevOps|Auto DevOps (Beta)" msgstr "" -msgid "AutoDevOps|Auto DevOps can be activated for this project. It will automatically build, test, and deploy your application based on a predefined CI/CD configuration." -msgstr "" - msgid "AutoDevOps|Auto DevOps documentation" msgstr "" msgid "AutoDevOps|Enable in settings" msgstr "" +msgid "AutoDevOps|It will automatically build, test, and deploy your application based on a predefined CI/CD configuration." +msgstr "" + msgid "AutoDevOps|Learn more in the %{link_to_documentation}" msgstr "" +msgid "AutoDevOps|You can activate %{link_to_settings} for this project." +msgstr "" + msgid "Branch" msgid_plural "Branches" msgstr[0] "" @@ -180,6 +192,9 @@ msgstr[1] "" msgid "Branch %{branch_name} was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}" msgstr "" +msgid "Branch has changed" +msgstr "" + msgid "BranchSwitcherPlaceholder|Search branches" msgstr "" @@ -375,6 +390,9 @@ msgstr "" msgid "CiStatus|running" msgstr "" +msgid "CircuitBreakerApiLink|circuitbreaker api" +msgstr "" + msgid "Clone repository" msgstr "" @@ -384,6 +402,9 @@ msgstr "" msgid "ClusterIntegration|A %{link_to_container_project} must have been created under this account" msgstr "" +msgid "ClusterIntegration|Cluster details" +msgstr "" + msgid "ClusterIntegration|Cluster integration" msgstr "" @@ -435,6 +456,9 @@ msgstr "" msgid "ClusterIntegration|Make sure your account %{link_to_requirements} to create clusters" msgstr "" +msgid "ClusterIntegration|Manage Cluster integration on your GitLab project" +msgstr "" + msgid "ClusterIntegration|Manage your cluster by visiting %{link_gke}" msgstr "" @@ -459,7 +483,7 @@ msgstr "" msgid "ClusterIntegration|Removing cluster integration will remove the cluster configuration you have added to this project. It will not delete your project." msgstr "" -msgid "ClusterIntegration|Save" +msgid "ClusterIntegration|See and edit the details for your cluster" msgstr "" msgid "ClusterIntegration|See machine types" @@ -614,6 +638,9 @@ msgstr "" msgid "Create merge request" msgstr "" +msgid "Create new branch" +msgstr "" + msgid "Create new..." msgstr "" @@ -1021,6 +1048,9 @@ msgstr "" msgid "Login" msgstr "" +msgid "Maximum git storage failures" +msgstr "" + msgid "Median" msgstr "" @@ -1347,6 +1377,9 @@ msgstr "" msgid "Profiles|your account" msgstr "" +msgid "Project '%{project_name}' is in the process of being deleted." +msgstr "" + msgid "Project '%{project_name}' queued for deletion." msgstr "" @@ -1356,9 +1389,6 @@ msgstr "" msgid "Project '%{project_name}' was successfully updated." msgstr "" -msgid "Project '%{project_name}' will be deleted." -msgstr "" - msgid "Project access must be granted explicitly to each user." msgstr "" @@ -1494,6 +1524,9 @@ msgstr "" msgid "SSH Keys" msgstr "" +msgid "Save" +msgstr "" + msgid "Save changes" msgstr "" @@ -1512,6 +1545,15 @@ msgstr "" msgid "Search branches and tags" msgstr "" +msgid "Seconds before reseting failure information" +msgstr "" + +msgid "Seconds to wait after a storage failure" +msgstr "" + +msgid "Seconds to wait for a storage access attempt" +msgstr "" + msgid "Select Archive Format" msgstr "" @@ -1714,6 +1756,9 @@ msgstr "" msgid "The issue stage shows the time it takes from creating an issue to assigning the issue to a milestone, or add the issue to a list on your Issue Board. Begin creating issues to see data for this stage." msgstr "" +msgid "The number of failures of after which GitLab will completely prevent access to the storage. The number of failures can be reset in the admin interface: %{link_to_health_page} or using the %{api_documentation_link}." +msgstr "" + msgid "The phase of the development lifecycle." msgstr "" @@ -1744,6 +1789,12 @@ msgstr "" msgid "The testing stage shows the time GitLab CI takes to run every pipeline for the related merge request. The data will automatically be added after your first pipeline finishes running." msgstr "" +msgid "The time in seconds GitLab will keep failure information. When no failures occur during this time, information about the mount is reset." +msgstr "" + +msgid "The time in seconds GitLab will try to access storage. After this time a timeout error will be raised." +msgstr "" + msgid "The time taken by each data entry gathered by that stage." msgstr "" @@ -1753,6 +1804,9 @@ msgstr "" msgid "There are problems accessing Git storage: " msgstr "" +msgid "This branch has changed since you started editing. Would you like to create a new branch?" +msgstr "" + msgid "This is a confidential issue." msgstr "" @@ -1976,6 +2030,9 @@ msgstr "" msgid "We don't have enough data to show this stage." msgstr "" +msgid "When access to a storage fails. GitLab will prevent access to the storage for the time specified here. This allows the filesystem to recover. Repositories on failing shards are temporarly unavailable" +msgstr "" + msgid "Wiki" msgstr "" diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb index 6987c1f8f85..8080deda675 100644 --- a/qa/qa/page/group/show.rb +++ b/qa/qa/page/group/show.rb @@ -2,10 +2,6 @@ module QA module Page module Group class Show < Page::Base - def go_to_subgroups - click_link 'Subgroups' - end - def go_to_subgroup(name) click_link name end @@ -15,11 +11,19 @@ module QA end def go_to_new_subgroup - click_on 'New Subgroup' + within '.new-project-subgroup' do + find('.dropdown-toggle').click + find("li[data-value='new-subgroup']").click + end + find("input[data-action='new-subgroup']").click end def go_to_new_project - click_on 'New Project' + within '.new-project-subgroup' do + find('.dropdown-toggle').click + find("li[data-value='new-project']").click + end + find("input[data-action='new-project']").click end end end diff --git a/qa/qa/scenario/gitlab/project/create.rb b/qa/qa/scenario/gitlab/project/create.rb index 7b614bfdd94..bb3b9e19c0f 100644 --- a/qa/qa/scenario/gitlab/project/create.rb +++ b/qa/qa/scenario/gitlab/project/create.rb @@ -15,8 +15,6 @@ module QA Scenario::Gitlab::Sandbox::Prepare.perform Page::Group::Show.perform do |page| - page.go_to_subgroups - if page.has_subgroup?(Runtime::Namespace.name) page.go_to_subgroup(Runtime::Namespace.name) else diff --git a/spec/controllers/admin/hooks_controller_spec.rb b/spec/controllers/admin/hooks_controller_spec.rb index 1d1070e90f4..e6ba596117a 100644 --- a/spec/controllers/admin/hooks_controller_spec.rb +++ b/spec/controllers/admin/hooks_controller_spec.rb @@ -20,7 +20,7 @@ describe Admin::HooksController do post :create, hook: hook_params - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(SystemHook.all.size).to eq(1) expect(SystemHook.first).to have_attributes(hook_params) end diff --git a/spec/controllers/admin/impersonations_controller_spec.rb b/spec/controllers/admin/impersonations_controller_spec.rb index 8f1f0ba89ff..944680b3f42 100644 --- a/spec/controllers/admin/impersonations_controller_spec.rb +++ b/spec/controllers/admin/impersonations_controller_spec.rb @@ -22,7 +22,7 @@ describe Admin::ImpersonationsController do it "responds with status 404" do delete :destroy - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "doesn't sign us in" do @@ -46,7 +46,7 @@ describe Admin::ImpersonationsController do it "responds with status 404" do delete :destroy - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "doesn't sign us in as the impersonator" do @@ -65,7 +65,7 @@ describe Admin::ImpersonationsController do it "responds with status 404" do delete :destroy - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "doesn't sign us in as the impersonator" do diff --git a/spec/controllers/admin/projects_controller_spec.rb b/spec/controllers/admin/projects_controller_spec.rb index 373260b3978..d5a3c250f31 100644 --- a/spec/controllers/admin/projects_controller_spec.rb +++ b/spec/controllers/admin/projects_controller_spec.rb @@ -27,7 +27,7 @@ describe Admin::ProjectsController do get :index - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).not_to match(pending_delete_project.name) expect(response.body).to match(project.name) end diff --git a/spec/controllers/admin/runners_controller_spec.rb b/spec/controllers/admin/runners_controller_spec.rb index b5fe40d0510..312dbdd0624 100644 --- a/spec/controllers/admin/runners_controller_spec.rb +++ b/spec/controllers/admin/runners_controller_spec.rb @@ -11,7 +11,7 @@ describe Admin::RunnersController do it 'lists all runners' do get :index - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -19,13 +19,13 @@ describe Admin::RunnersController do it 'shows a particular runner' do get :show, id: runner.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'shows 404 for unknown runner' do get :show, id: 0 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -39,7 +39,7 @@ describe Admin::RunnersController do runner.reload - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(runner.description).to eq(new_desc) end end @@ -48,7 +48,7 @@ describe Admin::RunnersController do it 'destroys the runner' do delete :destroy, id: runner.id - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(Ci::Runner.find_by(id: runner.id)).to be_nil end end @@ -63,7 +63,7 @@ describe Admin::RunnersController do runner.reload - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(runner.active).to eq(true) end end @@ -78,7 +78,7 @@ describe Admin::RunnersController do runner.reload - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(runner.active).to eq(false) end end diff --git a/spec/controllers/admin/services_controller_spec.rb b/spec/controllers/admin/services_controller_spec.rb index 249bd948847..701211c2586 100644 --- a/spec/controllers/admin/services_controller_spec.rb +++ b/spec/controllers/admin/services_controller_spec.rb @@ -20,7 +20,7 @@ describe Admin::ServicesController do it 'successfully displays the template' do get :edit, id: service.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -46,7 +46,7 @@ describe Admin::ServicesController do put :update, id: service.id, service: { active: true } - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end it 'does not call the propagation worker when service is not active' do @@ -54,7 +54,7 @@ describe Admin::ServicesController do put :update, id: service.id, service: { properties: {} } - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end end diff --git a/spec/controllers/admin/spam_logs_controller_spec.rb b/spec/controllers/admin/spam_logs_controller_spec.rb index 585ca31389d..7a96ef6a5cc 100644 --- a/spec/controllers/admin/spam_logs_controller_spec.rb +++ b/spec/controllers/admin/spam_logs_controller_spec.rb @@ -14,7 +14,7 @@ describe Admin::SpamLogsController do it 'lists all spam logs' do get :index - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -22,14 +22,14 @@ describe Admin::SpamLogsController do it 'removes only the spam log when removing log' do expect { delete :destroy, id: first_spam.id }.to change { SpamLog.count }.by(-1) expect(User.find(user.id)).to be_truthy - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'removes user and his spam logs when removing the user' do delete :destroy, id: first_spam.id, remove_user: true expect(flash[:notice]).to eq "User #{user.username} was successfully removed." - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(SpamLog.count).to eq(0) expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound) end @@ -42,7 +42,7 @@ describe Admin::SpamLogsController do it 'submits the log as ham' do post :mark_as_ham, id: first_spam.id - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(SpamLog.find(first_spam.id).submitted_as_ham).to be_truthy end end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 25fe547ff37..f044a068938 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -19,7 +19,7 @@ describe Admin::UsersController do it 'deletes user and ghosts their contributions' do delete :destroy, id: user.username, format: :json - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(User.exists?(user.id)).to be_falsy expect(issue.reload.author).to be_ghost end @@ -27,7 +27,7 @@ describe Admin::UsersController do it 'deletes the user and their contributions when hard delete is specified' do delete :destroy, id: user.username, hard_delete: true, format: :json - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(User.exists?(user.id)).to be_falsy expect(Issue.exists?(issue.id)).to be_falsy end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 0a3a0f7da18..6802b839eaa 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -61,7 +61,7 @@ describe ApplicationController do context "when the 'private_token' param is populated with the private token" do it "logs the user in" do get :index, private_token: user.private_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).to eq("authenticated") end end @@ -70,7 +70,7 @@ describe ApplicationController do it "logs the user in" do @request.headers['PRIVATE-TOKEN'] = user.private_token get :index - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).to eq("authenticated") end end @@ -95,7 +95,7 @@ describe ApplicationController do context "when the 'personal_access_token' param is populated with the personal access token" do it "logs the user in" do get :index, private_token: personal_access_token.token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).to eq('authenticated') end end @@ -104,7 +104,7 @@ describe ApplicationController do it "logs the user in" do @request.headers["PRIVATE-TOKEN"] = personal_access_token.token get :index - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).to eq('authenticated') end end @@ -158,7 +158,7 @@ describe ApplicationController do it 'returns 200 response' do get :index, private_token: user.private_token, format: requested_format - expect(response).to have_http_status 200 + expect(response).to have_gitlab_http_status 200 end end @@ -166,7 +166,7 @@ describe ApplicationController do it 'returns 404 response' do get :index, private_token: user.private_token - expect(response).to have_http_status 404 + expect(response).to have_gitlab_http_status 404 end end end @@ -183,7 +183,7 @@ describe ApplicationController do context 'when the request format is atom' do it "logs the user in" do get :index, rss_token: user.rss_token, format: :atom - expect(response).to have_http_status 200 + expect(response).to have_gitlab_http_status 200 expect(response.body).to eq 'authenticated' end end @@ -191,7 +191,7 @@ describe ApplicationController do context 'when the request format is not atom' do it "doesn't log the user in" do get :index, rss_token: user.rss_token - expect(response.status).not_to have_http_status 200 + expect(response.status).not_to have_gitlab_http_status 200 expect(response.body).not_to eq 'authenticated' end end diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb index be27bbb4283..73fff6eb5ca 100644 --- a/spec/controllers/autocomplete_controller_spec.rb +++ b/spec/controllers/autocomplete_controller_spec.rb @@ -30,7 +30,7 @@ describe AutocompleteController do get(:users, project_id: 'unknown') end - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end end @@ -59,7 +59,7 @@ describe AutocompleteController do get(:users, group_id: 'unknown') end - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end end @@ -138,7 +138,7 @@ describe AutocompleteController do get(:users, project_id: project.id) end - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end describe 'GET #users with unknown project' do @@ -146,7 +146,7 @@ describe AutocompleteController do get(:users, project_id: 'unknown') end - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end describe 'GET #users with inaccessible group' do @@ -155,7 +155,7 @@ describe AutocompleteController do get(:users, group_id: user.namespace.id) end - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end describe 'GET #users with no project' do diff --git a/spec/controllers/boards/issues_controller_spec.rb b/spec/controllers/boards/issues_controller_spec.rb index 5163099cd98..44d504d5852 100644 --- a/spec/controllers/boards/issues_controller_spec.rb +++ b/spec/controllers/boards/issues_controller_spec.rb @@ -24,7 +24,7 @@ describe Boards::IssuesController do it 'returns a not found 404 response' do list_issues user: user, board: 999, list: list2 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -62,7 +62,7 @@ describe Boards::IssuesController do it 'returns a not found 404 response' do list_issues user: user, board: board, list: 999 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -93,7 +93,7 @@ describe Boards::IssuesController do it 'returns a forbidden 403 response' do list_issues user: user, board: board, list: list2 - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -116,7 +116,7 @@ describe Boards::IssuesController do it 'returns a successful 200 response' do create_issue user: user, board: board, list: list1, title: 'New issue' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns the created issue' do @@ -131,7 +131,7 @@ describe Boards::IssuesController do it 'returns an unprocessable entity 422 response' do create_issue user: user, board: board, list: list1, title: nil - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -141,7 +141,7 @@ describe Boards::IssuesController do create_issue user: user, board: board, list: list, title: 'New issue' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -149,7 +149,7 @@ describe Boards::IssuesController do it 'returns a not found 404 response' do create_issue user: user, board: 999, list: list1, title: 'New issue' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -157,7 +157,7 @@ describe Boards::IssuesController do it 'returns a not found 404 response' do create_issue user: user, board: board, list: 999, title: 'New issue' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -166,7 +166,7 @@ describe Boards::IssuesController do it 'returns a forbidden 403 response' do create_issue user: guest, board: board, list: list1, title: 'New issue' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -187,7 +187,7 @@ describe Boards::IssuesController do it 'returns a successful 200 response' do move user: user, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'moves issue to the desired list' do @@ -201,19 +201,19 @@ describe Boards::IssuesController do it 'returns a unprocessable entity 422 response for invalid lists' do move user: user, board: board, issue: issue, from_list_id: nil, to_list_id: nil - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end it 'returns a not found 404 response for invalid board id' do move user: user, board: 999, issue: issue, from_list_id: list1.id, to_list_id: list2.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a not found 404 response for invalid issue id' do move user: user, board: board, issue: double(id: 999), from_list_id: list1.id, to_list_id: list2.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -227,7 +227,7 @@ describe Boards::IssuesController do it 'returns a forbidden 403 response' do move user: guest, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end diff --git a/spec/controllers/boards/lists_controller_spec.rb b/spec/controllers/boards/lists_controller_spec.rb index b11fce0fa58..a2b432af23a 100644 --- a/spec/controllers/boards/lists_controller_spec.rb +++ b/spec/controllers/boards/lists_controller_spec.rb @@ -15,7 +15,7 @@ describe Boards::ListsController do it 'returns a successful 200 response' do read_board_list user: user, board: board - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'application/json' end @@ -39,7 +39,7 @@ describe Boards::ListsController do it 'returns a forbidden 403 response' do read_board_list user: user, board: board - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -60,7 +60,7 @@ describe Boards::ListsController do it 'returns a successful 200 response' do create_board_list user: user, board: board, label_id: label.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns the created list' do @@ -75,7 +75,7 @@ describe Boards::ListsController do it 'returns a not found 404 response' do create_board_list user: user, board: board, label_id: nil - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -85,7 +85,7 @@ describe Boards::ListsController do create_board_list user: user, board: board, label_id: label.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -96,7 +96,7 @@ describe Boards::ListsController do create_board_list user: guest, board: board, label_id: label.id - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -119,7 +119,7 @@ describe Boards::ListsController do it 'returns a successful 200 response' do move user: user, board: board, list: planning, position: 1 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'moves the list to the desired position' do @@ -133,7 +133,7 @@ describe Boards::ListsController do it 'returns an unprocessable entity 422 response' do move user: user, board: board, list: planning, position: 6 - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -141,7 +141,7 @@ describe Boards::ListsController do it 'returns a not found 404 response' do move user: user, board: board, list: 999, position: 1 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -149,7 +149,7 @@ describe Boards::ListsController do it 'returns a forbidden 403 response' do move user: guest, board: board, list: planning, position: 6 - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -172,7 +172,7 @@ describe Boards::ListsController do it 'returns a successful 200 response' do remove_board_list user: user, board: board, list: planning - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'removes list from board' do @@ -184,7 +184,7 @@ describe Boards::ListsController do it 'returns a not found 404 response' do remove_board_list user: user, board: board, list: 999 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -192,7 +192,7 @@ describe Boards::ListsController do it 'returns a forbidden 403 response' do remove_board_list user: guest, board: board, list: planning - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -212,7 +212,7 @@ describe Boards::ListsController do it 'returns a successful 200 response' do generate_default_lists user: user, board: board - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns the defaults lists' do @@ -228,7 +228,7 @@ describe Boards::ListsController do generate_default_lists user: user, board: board - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -236,7 +236,7 @@ describe Boards::ListsController do it 'returns a forbidden 403 response' do generate_default_lists user: guest, board: board - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end diff --git a/spec/controllers/dashboard/milestones_controller_spec.rb b/spec/controllers/dashboard/milestones_controller_spec.rb index 2dcb67d50f4..2f3d7be9abe 100644 --- a/spec/controllers/dashboard/milestones_controller_spec.rb +++ b/spec/controllers/dashboard/milestones_controller_spec.rb @@ -32,7 +32,7 @@ describe Dashboard::MilestonesController do it 'shows milestone page' do view_milestone - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/dashboard/todos_controller_spec.rb b/spec/controllers/dashboard/todos_controller_spec.rb index 9df4ebf2fa0..d862e1447e3 100644 --- a/spec/controllers/dashboard/todos_controller_spec.rb +++ b/spec/controllers/dashboard/todos_controller_spec.rb @@ -18,19 +18,19 @@ describe Dashboard::TodosController do get :index, project_id: unauthorized_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'renders 404 when given project does not exists' do get :index, project_id: 999 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'renders 200 when filtering for "any project" todos' do get :index, project_id: '' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'renders 200 when user has access on given project' do @@ -38,7 +38,7 @@ describe Dashboard::TodosController do get :index, project_id: authorized_project.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -61,7 +61,7 @@ describe Dashboard::TodosController do get :index, page: last_page expect(assigns(:todos).current_page).to eq(last_page) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not redirect to external sites when provided a host field' do @@ -104,7 +104,7 @@ describe Dashboard::TodosController do patch :restore, id: todo.id expect(todo.reload).to be_pending - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq({ "count" => "1", "done_count" => "0" }) end end @@ -118,7 +118,7 @@ describe Dashboard::TodosController do todos.each do |todo| expect(todo.reload).to be_pending end - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq({ 'count' => '2', 'done_count' => '0' }) end end diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb index cce53f6697c..9c6d584f59b 100644 --- a/spec/controllers/groups/group_members_controller_spec.rb +++ b/spec/controllers/groups/group_members_controller_spec.rb @@ -8,7 +8,7 @@ describe Groups::GroupMembersController do it 'renders index with 200 status code' do get :index, group_id: group - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template(:index) end end @@ -30,7 +30,7 @@ describe Groups::GroupMembersController do user_ids: group_user.id, access_level: Gitlab::Access::GUEST - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(group.users).not_to include group_user end end @@ -73,7 +73,7 @@ describe Groups::GroupMembersController do it 'returns 403' do delete :destroy, group_id: group, id: 42 - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -86,7 +86,7 @@ describe Groups::GroupMembersController do it 'returns 403' do delete :destroy, group_id: group, id: member - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(group.members).to include member end end @@ -123,7 +123,7 @@ describe Groups::GroupMembersController do it 'returns 404' do delete :leave, group_id: group - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -144,7 +144,7 @@ describe Groups::GroupMembersController do it 'supports json request' do delete :leave, group_id: group, format: :json - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['notice']).to eq "You left the \"#{group.name}\" group." end end @@ -157,7 +157,7 @@ describe Groups::GroupMembersController do it 'cannot removes himself from the group' do delete :leave, group_id: group - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -204,7 +204,7 @@ describe Groups::GroupMembersController do it 'returns 403' do post :approve_access_request, group_id: group, id: 42 - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -217,7 +217,7 @@ describe Groups::GroupMembersController do it 'returns 403' do post :approve_access_request, group_id: group, id: member - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(group.members).not_to include member end end diff --git a/spec/controllers/groups/labels_controller_spec.rb b/spec/controllers/groups/labels_controller_spec.rb index 899d8ebd12b..da54aa9054c 100644 --- a/spec/controllers/groups/labels_controller_spec.rb +++ b/spec/controllers/groups/labels_controller_spec.rb @@ -16,7 +16,7 @@ describe Groups::LabelsController do post :toggle_subscription, group_id: group.to_param, id: label.to_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb index fbbc67f3ae0..c1aba46be04 100644 --- a/spec/controllers/groups/milestones_controller_spec.rb +++ b/spec/controllers/groups/milestones_controller_spec.rb @@ -35,7 +35,7 @@ describe Groups::MilestonesController do it 'shows group milestones page' do get :index, group_id: group.to_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'as JSON' do @@ -51,7 +51,7 @@ describe Groups::MilestonesController do expect(milestones.count).to eq(2) expect(milestones.first["title"]).to eq("group milestone") expect(milestones.second["title"]).to eq("legacy") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'application/json' end end @@ -153,7 +153,7 @@ describe Groups::MilestonesController do it 'does not redirect' do get :index, group_id: group.to_param - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -172,7 +172,7 @@ describe Groups::MilestonesController do it 'does not redirect' do get :show, group_id: group.to_param, id: title - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -242,7 +242,7 @@ describe Groups::MilestonesController do group_id: group.to_param, milestone: { title: title } - expect(response).not_to have_http_status(404) + expect(response).not_to have_gitlab_http_status(404) end it 'does not redirect to the correct casing' do @@ -250,7 +250,7 @@ describe Groups::MilestonesController do group_id: group.to_param, milestone: { title: title } - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -262,7 +262,7 @@ describe Groups::MilestonesController do group_id: redirect_route.path, milestone: { title: title } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/groups/settings/ci_cd_controller_spec.rb b/spec/controllers/groups/settings/ci_cd_controller_spec.rb index 2e0efb57c74..e9f0924caba 100644 --- a/spec/controllers/groups/settings/ci_cd_controller_spec.rb +++ b/spec/controllers/groups/settings/ci_cd_controller_spec.rb @@ -13,7 +13,7 @@ describe Groups::Settings::CiCdController do it 'renders show with 200 status code' do get :show, group_id: group - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template(:show) end end diff --git a/spec/controllers/groups/variables_controller_spec.rb b/spec/controllers/groups/variables_controller_spec.rb index 02f2fa46047..8ea98cd9e8f 100644 --- a/spec/controllers/groups/variables_controller_spec.rb +++ b/spec/controllers/groups/variables_controller_spec.rb @@ -48,7 +48,7 @@ describe Groups::VariablesController do post :update, group_id: group, id: variable.id, variable: { key: '?', value: variable.value } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template :show end end diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb index 5036c1d2226..a9cfd964dd5 100644 --- a/spec/controllers/groups_controller_spec.rb +++ b/spec/controllers/groups_controller_spec.rb @@ -263,7 +263,7 @@ describe GroupsController do it 'updates the path successfully' do post :update, id: group.to_param, group: { path: 'new_path' } - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(controller).to set_flash[:notice] end @@ -334,7 +334,7 @@ describe GroupsController do it 'does not redirect' do get :issues, id: group.to_param - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -353,7 +353,7 @@ describe GroupsController do it 'does not redirect' do get :show, id: group.to_param - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -420,13 +420,13 @@ describe GroupsController do it 'does not 404' do post :update, id: group.to_param.upcase, group: { path: 'new_path' } - expect(response).not_to have_http_status(404) + expect(response).not_to have_gitlab_http_status(404) end it 'does not redirect to the correct casing' do post :update, id: group.to_param.upcase, group: { path: 'new_path' } - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -436,7 +436,7 @@ describe GroupsController do it 'returns not found' do post :update, id: redirect_route.path, group: { path: 'new_path' } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -446,13 +446,13 @@ describe GroupsController do it 'does not 404' do delete :destroy, id: group.to_param.upcase - expect(response).not_to have_http_status(404) + expect(response).not_to have_gitlab_http_status(404) end it 'does not redirect to the correct casing' do delete :destroy, id: group.to_param.upcase - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -462,7 +462,7 @@ describe GroupsController do it 'returns not found' do delete :destroy, id: redirect_route.path - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/health_check_controller_spec.rb b/spec/controllers/health_check_controller_spec.rb index 03da6287774..2cead1770c9 100644 --- a/spec/controllers/health_check_controller_spec.rb +++ b/spec/controllers/health_check_controller_spec.rb @@ -100,7 +100,7 @@ describe HealthCheckController do it 'supports failure plaintext response' do get :index - expect(response).to have_http_status(500) + expect(response).to have_gitlab_http_status(500) expect(response.content_type).to eq 'text/plain' expect(response.body).to include('The server is on fire') end @@ -108,7 +108,7 @@ describe HealthCheckController do it 'supports failure json response' do get :index, format: :json - expect(response).to have_http_status(500) + expect(response).to have_gitlab_http_status(500) expect(response.content_type).to eq 'application/json' expect(json_response['healthy']).to be false expect(json_response['message']).to include('The server is on fire') @@ -117,7 +117,7 @@ describe HealthCheckController do it 'supports failure xml response' do get :index, format: :xml - expect(response).to have_http_status(500) + expect(response).to have_gitlab_http_status(500) expect(response.content_type).to eq 'application/xml' expect(xml_response['healthy']).to be false expect(xml_response['message']).to include('The server is on fire') @@ -126,7 +126,7 @@ describe HealthCheckController do it 'supports failure responses for specific checks' do get :index, checks: 'email', format: :json - expect(response).to have_http_status(500) + expect(response).to have_gitlab_http_status(500) expect(response.content_type).to eq 'application/json' expect(json_response['healthy']).to be false expect(json_response['message']).to include('Email is on fire') diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index d3489324a9c..f75048f422c 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -100,7 +100,7 @@ describe HelpController do context 'for UI Development Kit' do it 'renders found' do get :ui - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb index e00403118a0..6c09ca7dc66 100644 --- a/spec/controllers/invites_controller_spec.rb +++ b/spec/controllers/invites_controller_spec.rb @@ -15,7 +15,7 @@ describe InvitesController do get :accept, id: token member.reload - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(member.user).to eq(user) expect(flash[:notice]).to include 'You have been granted' end @@ -26,7 +26,7 @@ describe InvitesController do get :decline, id: token expect {member.reload}.to raise_error ActiveRecord::RecordNotFound - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(flash[:notice]).to include 'You have declined the invitation to join' end end diff --git a/spec/controllers/notification_settings_controller_spec.rb b/spec/controllers/notification_settings_controller_spec.rb index bef815ee1f7..9014b8b5084 100644 --- a/spec/controllers/notification_settings_controller_spec.rb +++ b/spec/controllers/notification_settings_controller_spec.rb @@ -110,7 +110,7 @@ describe NotificationSettingsController do project_id: private_project.id, notification_setting: { level: :participating } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -172,7 +172,7 @@ describe NotificationSettingsController do id: notification_setting, notification_setting: { level: :participating } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/oauth/applications_controller_spec.rb b/spec/controllers/oauth/applications_controller_spec.rb index 552899eb36c..b38652e7ab9 100644 --- a/spec/controllers/oauth/applications_controller_spec.rb +++ b/spec/controllers/oauth/applications_controller_spec.rb @@ -12,7 +12,7 @@ describe Oauth::ApplicationsController do it 'shows list of applications' do get :index - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'redirects back to profile page if OAuth applications are disabled' do @@ -21,7 +21,7 @@ describe Oauth::ApplicationsController do get :index - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(response).to redirect_to(profile_path) end end diff --git a/spec/controllers/oauth/authorizations_controller_spec.rb b/spec/controllers/oauth/authorizations_controller_spec.rb index ac7f73c6e81..004b463e745 100644 --- a/spec/controllers/oauth/authorizations_controller_spec.rb +++ b/spec/controllers/oauth/authorizations_controller_spec.rb @@ -28,7 +28,7 @@ describe Oauth::AuthorizationsController do it 'returns 200 code and renders error view' do get :new - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template('doorkeeper/authorizations/error') end end @@ -37,7 +37,7 @@ describe Oauth::AuthorizationsController do it 'returns 200 code and renders view' do get :new, params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template('doorkeeper/authorizations/new') end @@ -48,7 +48,7 @@ describe Oauth::AuthorizationsController do get :new, params expect(request.session['user_return_to']).to be_nil - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end end diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb index cdaa88bbf5d..8778bff1190 100644 --- a/spec/controllers/passwords_controller_spec.rb +++ b/spec/controllers/passwords_controller_spec.rb @@ -12,7 +12,7 @@ describe PasswordsController do post :create - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end diff --git a/spec/controllers/profiles/accounts_controller_spec.rb b/spec/controllers/profiles/accounts_controller_spec.rb index d387aba227b..f8d9d7e39ee 100644 --- a/spec/controllers/profiles/accounts_controller_spec.rb +++ b/spec/controllers/profiles/accounts_controller_spec.rb @@ -11,7 +11,7 @@ describe Profiles::AccountsController do it 'renders 404 if someone tries to unlink a non existent provider' do delete :unlink, provider: 'github' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end [:saml, :cas3].each do |provider| @@ -23,7 +23,7 @@ describe Profiles::AccountsController do delete :unlink, provider: provider.to_s - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(user.reload.identities).to include(identity) end end @@ -38,7 +38,7 @@ describe Profiles::AccountsController do delete :unlink, provider: provider.to_s - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(user.reload.identities).not_to include(identity) end end diff --git a/spec/controllers/projects/artifacts_controller_spec.rb b/spec/controllers/projects/artifacts_controller_spec.rb index d0992719171..d1051741430 100644 --- a/spec/controllers/projects/artifacts_controller_spec.rb +++ b/spec/controllers/projects/artifacts_controller_spec.rb @@ -60,7 +60,7 @@ describe Projects::ArtifactsController do it 'renders the file view' do get :file, namespace_id: project.namespace, project_id: project, job_id: job, path: 'ci_artifacts.txt' - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -78,7 +78,7 @@ describe Projects::ArtifactsController do it 'renders the file view' do get :file, namespace_id: project.namespace, project_id: project, job_id: job, path: 'ci_artifacts.txt' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('projects/artifacts/file') end end @@ -106,7 +106,7 @@ describe Projects::ArtifactsController do it 'does not redirect the request' do get :file, namespace_id: private_project.namespace, project_id: private_project, job_id: job, path: 'ci_artifacts.txt' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('projects/artifacts/file') end end @@ -143,7 +143,7 @@ describe Projects::ArtifactsController do context 'cannot find the job' do shared_examples 'not found' do - it { expect(response).to have_http_status(:not_found) } + it { expect(response).to have_gitlab_http_status(:not_found) } end context 'has no such ref' do diff --git a/spec/controllers/projects/badges_controller_spec.rb b/spec/controllers/projects/badges_controller_spec.rb index d68200164e4..e7cddf8cfbf 100644 --- a/spec/controllers/projects/badges_controller_spec.rb +++ b/spec/controllers/projects/badges_controller_spec.rb @@ -13,13 +13,13 @@ describe Projects::BadgesController do it 'requests the pipeline badge successfully' do get_badge(:pipeline) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end it 'requests the coverage badge successfully' do get_badge(:coverage) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end def get_badge(badge) diff --git a/spec/controllers/projects/blame_controller_spec.rb b/spec/controllers/projects/blame_controller_spec.rb index c086b386381..54282aa4001 100644 --- a/spec/controllers/projects/blame_controller_spec.rb +++ b/spec/controllers/projects/blame_controller_spec.rb @@ -28,7 +28,7 @@ describe Projects::BlameController do context "invalid file" do let(:id) { 'master/files/ruby/missing_file.rb'} - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end end end diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index fb76b7fdf38..6a1c07b4a0b 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -153,7 +153,7 @@ describe Projects::BlobController do end it 'redirects to blob show' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -167,7 +167,7 @@ describe Projects::BlobController do end it 'redirects to blob show' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/projects/boards_controller_spec.rb b/spec/controllers/projects/boards_controller_spec.rb index 9e2e9a39481..84cde33d944 100644 --- a/spec/controllers/projects/boards_controller_spec.rb +++ b/spec/controllers/projects/boards_controller_spec.rb @@ -45,7 +45,7 @@ describe Projects::BoardsController do it 'returns a not found 404 response' do list_boards - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -85,7 +85,7 @@ describe Projects::BoardsController do it 'returns a not found 404 response' do read_board board: board - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -95,7 +95,7 @@ describe Projects::BoardsController do read_board board: another_board - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index 3b3b63444c7..973d6fed288 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -128,7 +128,7 @@ describe Projects::BranchesController do issue_iid: issue.iid expect(response.location).to include(project_new_blob_path(project, branch)) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -161,7 +161,7 @@ describe Projects::BranchesController do it 'returns a successful 200 response' do create_branch name: 'my-branch', ref: 'master' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns the created branch' do @@ -175,7 +175,7 @@ describe Projects::BranchesController do it 'returns an unprocessable entity 422 response' do create_branch name: "", ref: "" - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -202,7 +202,7 @@ describe Projects::BranchesController do namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(303) + expect(response).to have_gitlab_http_status(303) end end @@ -226,28 +226,28 @@ describe Projects::BranchesController do context "valid branch name, valid source" do let(:branch) { "feature" } - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } it { expect(response.body).to be_blank } end context "valid branch name with unencoded slashes" do let(:branch) { "improve/awesome" } - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } it { expect(response.body).to be_blank } end context "valid branch name with encoded slashes" do let(:branch) { "improve%2Fawesome" } - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } it { expect(response.body).to be_blank } end context "invalid branch name, valid ref" do let(:branch) { "no-branch" } - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } it { expect(response.body).to be_blank } end end @@ -263,7 +263,7 @@ describe Projects::BranchesController do expect(json_response).to eql("message" => 'Branch was removed') end - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } end context 'valid branch name with unencoded slashes' do @@ -273,7 +273,7 @@ describe Projects::BranchesController do expect(json_response).to eql('message' => 'Branch was removed') end - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } end context "valid branch name with encoded slashes" do @@ -283,7 +283,7 @@ describe Projects::BranchesController do expect(json_response).to eql('message' => 'Branch was removed') end - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } end context 'invalid branch name, valid ref' do @@ -293,7 +293,7 @@ describe Projects::BranchesController do expect(json_response).to eql('message' => 'No such branch') end - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end end @@ -341,7 +341,7 @@ describe Projects::BranchesController do it 'responds with status 404' do destroy_all_merged - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -379,7 +379,7 @@ describe Projects::BranchesController do project_id: project, format: :html - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb index 7985028d73b..bd924a1c7be 100644 --- a/spec/controllers/projects/clusters_controller_spec.rb +++ b/spec/controllers/projects/clusters_controller_spec.rb @@ -169,7 +169,7 @@ describe Projects::ClustersController do it "responds with matching schema" do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('cluster_status') end end @@ -189,14 +189,14 @@ describe Projects::ClustersController do it "allows to update cluster" do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to include("Save") end it "allows remove integration" do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.body).to include("Remove integration") end end @@ -207,7 +207,7 @@ describe Projects::ClustersController do it "does not allow to access page" do subject - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -251,7 +251,7 @@ describe Projects::ClustersController do it "rejects changes" do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template(:show) end end @@ -263,7 +263,7 @@ describe Projects::ClustersController do it "does not allow to update cluster" do subject - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -292,7 +292,7 @@ describe Projects::ClustersController do it "does not allow to destroy cluster" do subject - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index df53863482d..4612fc6e441 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -157,7 +157,7 @@ describe Projects::CommitController do id: commit.id) expect(response).not_to be_success - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -206,7 +206,7 @@ describe Projects::CommitController do id: master_pickable_commit.id) expect(response).not_to be_success - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -286,7 +286,7 @@ describe Projects::CommitController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -298,7 +298,7 @@ describe Projects::CommitController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -309,7 +309,7 @@ describe Projects::CommitController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -356,7 +356,7 @@ describe Projects::CommitController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb index b4f9fd9b7a2..fe5818da0bc 100644 --- a/spec/controllers/projects/compare_controller_spec.rb +++ b/spec/controllers/projects/compare_controller_spec.rb @@ -133,7 +133,7 @@ describe Projects::CompareController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -145,7 +145,7 @@ describe Projects::CompareController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -156,7 +156,7 @@ describe Projects::CompareController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -166,7 +166,7 @@ describe Projects::CompareController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/deployments_controller_spec.rb b/spec/controllers/projects/deployments_controller_spec.rb index 3daff1eeea3..3164fd5c143 100644 --- a/spec/controllers/projects/deployments_controller_spec.rb +++ b/spec/controllers/projects/deployments_controller_spec.rb @@ -67,7 +67,7 @@ describe Projects::DeploymentsController do it 'returns a empty response 204 resposne' do get :metrics, deployment_params(id: deployment.id) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(response.body).to eq('') end end @@ -142,7 +142,7 @@ describe Projects::DeploymentsController do it 'returns a empty response 204 response' do get :additional_metrics, deployment_params(id: deployment.id, format: :json) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(response.body).to eq('') end end diff --git a/spec/controllers/projects/discussions_controller_spec.rb b/spec/controllers/projects/discussions_controller_spec.rb index fe62898fa9b..3bf676637a2 100644 --- a/spec/controllers/projects/discussions_controller_spec.rb +++ b/spec/controllers/projects/discussions_controller_spec.rb @@ -25,7 +25,7 @@ describe Projects::DiscussionsController do it "returns status 404" do post :resolve, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -42,7 +42,7 @@ describe Projects::DiscussionsController do it "returns status 404" do post :resolve, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -69,7 +69,7 @@ describe Projects::DiscussionsController do it "returns status 200" do post :resolve, request_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -86,7 +86,7 @@ describe Projects::DiscussionsController do it "returns status 404" do delete :unresolve, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -103,7 +103,7 @@ describe Projects::DiscussionsController do it "returns status 404" do delete :unresolve, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -117,7 +117,7 @@ describe Projects::DiscussionsController do it "returns status 200" do delete :unresolve, request_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index 5a95f4f6199..ff9ab53d8c3 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -19,7 +19,7 @@ describe Projects::EnvironmentsController do it 'responds with status code 200' do get :index, environment_params - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end @@ -59,7 +59,7 @@ describe Projects::EnvironmentsController do end it 'sets the polling interval header' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.headers['Poll-Interval']).to eq("3000") end end @@ -137,7 +137,7 @@ describe Projects::EnvironmentsController do params[:id] = 12345 get :show, params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -155,7 +155,7 @@ describe Projects::EnvironmentsController do patch_params = environment_params.merge(environment: { external_url: 'https://git.gitlab.com' }) patch :update, patch_params - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -166,7 +166,7 @@ describe Projects::EnvironmentsController do patch :stop, environment_params(format: :json) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -179,7 +179,7 @@ describe Projects::EnvironmentsController do patch :stop, environment_params(format: :json) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq( { 'redirect_url' => project_job_url(project, action) }) @@ -193,7 +193,7 @@ describe Projects::EnvironmentsController do patch :stop, environment_params(format: :json) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq( { 'redirect_url' => project_environment_url(project, environment) }) @@ -206,7 +206,7 @@ describe Projects::EnvironmentsController do it 'responds with a status code 200' do get :terminal, environment_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'loads the terminals for the enviroment' do @@ -220,7 +220,7 @@ describe Projects::EnvironmentsController do it 'responds with a status code 404' do get :terminal, environment_params(id: 666) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -244,7 +244,7 @@ describe Projects::EnvironmentsController do get :terminal_websocket_authorize, environment_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers["Content-Type"]).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.body).to eq('{"workhorse":"response"}') end @@ -254,7 +254,7 @@ describe Projects::EnvironmentsController do it 'returns 404' do get :terminal_websocket_authorize, environment_params(id: 666) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -290,7 +290,7 @@ describe Projects::EnvironmentsController do it 'returns a metrics JSON document' do get :metrics, environment_params(format: :json) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(json_response).to eq({}) end end @@ -330,7 +330,7 @@ describe Projects::EnvironmentsController do it 'returns a metrics JSON document' do get :additional_metrics, environment_params(format: :json) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(json_response).to eq({}) end end diff --git a/spec/controllers/projects/forks_controller_spec.rb b/spec/controllers/projects/forks_controller_spec.rb index dc8290c438e..1bedb8ebdff 100644 --- a/spec/controllers/projects/forks_controller_spec.rb +++ b/spec/controllers/projects/forks_controller_spec.rb @@ -89,7 +89,7 @@ describe Projects::ForksController do get_new - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -118,7 +118,7 @@ describe Projects::ForksController do post_create - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(response).to redirect_to(namespace_project_import_path(user.namespace, project)) end end diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index ed8088a46f0..aecdfb50759 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -20,7 +20,7 @@ describe Projects::IssuesController do get :index, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -28,7 +28,7 @@ describe Projects::IssuesController do it 'renders the "index" template' do get :index, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template(:index) end end @@ -45,7 +45,7 @@ describe Projects::IssuesController do it "returns index" do get :index, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns 301 if request path doesn't match project path" do @@ -59,7 +59,7 @@ describe Projects::IssuesController do project.save! get :index, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -89,7 +89,7 @@ describe Projects::IssuesController do page: last_page.to_param expect(assigns(:issues).current_page).to eq(last_page) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not redirect to external sites when provided a host field' do @@ -166,7 +166,7 @@ describe Projects::IssuesController do get :new, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -174,7 +174,7 @@ describe Projects::IssuesController do it 'renders the "new" template' do get :new, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template(:new) end end @@ -224,7 +224,7 @@ describe Projects::IssuesController do it 'moves issue to another project' do move_issue - expect(response).to have_http_status :ok + expect(response).to have_gitlab_http_status :ok expect(another_project.issues).not_to be_empty end end @@ -233,7 +233,7 @@ describe Projects::IssuesController do it 'responds with 404' do move_issue - expect(response).to have_http_status :not_found + expect(response).to have_gitlab_http_status :not_found end end @@ -329,14 +329,14 @@ describe Projects::IssuesController do sign_out(:user) go(id: unescaped_parameter_value.to_param) - expect(response).to have_http_status :not_found + expect(response).to have_gitlab_http_status :not_found end it 'returns 404 for non project members' do sign_in(non_member) go(id: unescaped_parameter_value.to_param) - expect(response).to have_http_status :not_found + expect(response).to have_gitlab_http_status :not_found end it 'returns 404 for project members with guest role' do @@ -344,21 +344,21 @@ describe Projects::IssuesController do project.team << [member, :guest] go(id: unescaped_parameter_value.to_param) - expect(response).to have_http_status :not_found + expect(response).to have_gitlab_http_status :not_found end it "returns #{http_status[:success]} for author" do sign_in(author) go(id: unescaped_parameter_value.to_param) - expect(response).to have_http_status http_status[:success] + expect(response).to have_gitlab_http_status http_status[:success] end it "returns #{http_status[:success]} for assignee" do sign_in(assignee) go(id: request_forgery_timing_attack.to_param) - expect(response).to have_http_status http_status[:success] + expect(response).to have_gitlab_http_status http_status[:success] end it "returns #{http_status[:success]} for project members" do @@ -366,14 +366,14 @@ describe Projects::IssuesController do project.team << [member, :developer] go(id: unescaped_parameter_value.to_param) - expect(response).to have_http_status http_status[:success] + expect(response).to have_gitlab_http_status http_status[:success] end it "returns #{http_status[:success]} for admin" do sign_in(admin) go(id: unescaped_parameter_value.to_param) - expect(response).to have_http_status http_status[:success] + expect(response).to have_gitlab_http_status http_status[:success] end end @@ -475,7 +475,7 @@ describe Projects::IssuesController do it 'returns 422 status' do update_issue - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -495,7 +495,7 @@ describe Projects::IssuesController do end it 'returns 200 status' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'accepts an issue after recaptcha is verified' do @@ -553,10 +553,33 @@ describe Projects::IssuesController do it 'returns 200' do go(id: issue.iid) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end + + describe 'GET #edit' do + it_behaves_like 'restricted action', success: 200 + + def go(id:) + get :edit, + namespace_id: project.namespace.to_param, + project_id: project, + id: id + end + end + + describe 'PUT #update' do + it_behaves_like 'restricted action', success: 302 + + def go(id:) + put :update, + namespace_id: project.namespace.to_param, + project_id: project, + id: id, + issue: { title: 'New title' } + end + end end describe 'POST #create' do @@ -778,7 +801,7 @@ describe Projects::IssuesController do it "rejects a developer to destroy an issue" do delete :destroy, namespace_id: project.namespace, project_id: project, id: issue.iid - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -794,7 +817,7 @@ describe Projects::IssuesController do it "deletes the issue" do delete :destroy, namespace_id: project.namespace, project_id: project, id: issue.iid - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./) end @@ -818,7 +841,7 @@ describe Projects::IssuesController do project_id: project, id: issue.iid, name: "thumbsup") end.to change { issue.award_emoji.count }.by(1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index d01339a0b88..f9688949a19 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -20,7 +20,7 @@ describe Projects::JobsController do end it 'has only pending builds' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:builds).first.status).to eq('pending') end end @@ -33,7 +33,7 @@ describe Projects::JobsController do end it 'has only running jobs' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:builds).first.status).to eq('running') end end @@ -46,7 +46,7 @@ describe Projects::JobsController do end it 'has only finished jobs' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:builds).first.status).to eq('success') end end @@ -62,7 +62,7 @@ describe Projects::JobsController do end it 'redirects to the page' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:builds).current_page).to eq(last_page) end end @@ -107,7 +107,7 @@ describe Projects::JobsController do end it 'has a job' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:build).id).to eq(job.id) end end @@ -118,7 +118,7 @@ describe Projects::JobsController do end it 'renders not_found' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -136,7 +136,7 @@ describe Projects::JobsController do end it 'exposes needed information' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['raw_path']).to match(/jobs\/\d+\/raw\z/) expect(json_response.dig('merge_request', 'path')).to match(/merge_requests\/\d+\z/) expect(json_response['new_issue_path']) @@ -163,7 +163,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :trace, pipeline: pipeline) } it 'returns a trace' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq job.id expect(json_response['status']).to eq job.status expect(json_response['html']).to eq('BUILD TRACE') @@ -174,7 +174,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, pipeline: pipeline) } it 'returns no traces' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq job.id expect(json_response['status']).to eq job.status expect(json_response['html']).to be_nil @@ -185,7 +185,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :unicode_trace, pipeline: pipeline) } it 'returns a trace with Unicode' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['id']).to eq job.id expect(json_response['status']).to eq job.status expect(json_response['html']).to include("ヾ(´༎ຶД༎ຶ`)ノ") @@ -212,7 +212,7 @@ describe Projects::JobsController do end it 'return a detailed job status in json' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['text']).to eq status.text expect(json_response['label']).to eq status.label expect(json_response['icon']).to eq status.icon @@ -232,7 +232,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :retryable, pipeline: pipeline) } it 'redirects to the retried job page' do - expect(response).to have_http_status(:found) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_job_path(id: Ci::Build.last.id)) end end @@ -241,7 +241,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, pipeline: pipeline) } it 'renders unprocessable_entity' do - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end @@ -268,7 +268,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :playable, pipeline: pipeline) } it 'redirects to the played job page' do - expect(response).to have_http_status(:found) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_job_path(id: job.id)) end @@ -281,7 +281,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, pipeline: pipeline) } it 'renders unprocessable_entity' do - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end @@ -304,7 +304,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :cancelable, pipeline: pipeline) } it 'redirects to the canceled job page' do - expect(response).to have_http_status(:found) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_job_path(id: job.id)) end @@ -317,7 +317,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :canceled, pipeline: pipeline) } it 'returns unprocessable_entity' do - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end @@ -342,7 +342,7 @@ describe Projects::JobsController do end it 'redirects to a index page' do - expect(response).to have_http_status(:found) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_jobs_path) end @@ -359,7 +359,7 @@ describe Projects::JobsController do end it 'redirects to a index page' do - expect(response).to have_http_status(:found) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_jobs_path) end end @@ -382,7 +382,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :erasable, :trace, pipeline: pipeline) } it 'redirects to the erased job page' do - expect(response).to have_http_status(:found) + expect(response).to have_gitlab_http_status(:found) expect(response).to redirect_to(namespace_project_job_path(id: job.id)) end @@ -400,7 +400,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :erased, pipeline: pipeline) } it 'returns unprocessable_entity' do - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_gitlab_http_status(:unprocessable_entity) end end @@ -420,7 +420,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, :trace, pipeline: pipeline) } it 'send a trace file' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type).to eq 'text/plain; charset=utf-8' expect(response.body).to eq 'BUILD TRACE' end @@ -430,7 +430,7 @@ describe Projects::JobsController do let(:job) { create(:ci_build, pipeline: pipeline) } it 'returns not_found' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/projects/labels_controller_spec.rb b/spec/controllers/projects/labels_controller_spec.rb index f4e2dca883d..cf83f2f3265 100644 --- a/spec/controllers/projects/labels_controller_spec.rb +++ b/spec/controllers/projects/labels_controller_spec.rb @@ -78,7 +78,7 @@ describe Projects::LabelsController do it 'creates labels' do post :generate, namespace_id: personal_project.namespace.to_param, project_id: personal_project - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -86,7 +86,7 @@ describe Projects::LabelsController do it 'creates labels' do post :generate, namespace_id: project.namespace.to_param, project_id: project - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end end @@ -97,7 +97,7 @@ describe Projects::LabelsController do toggle_subscription(label) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'allows user to toggle subscription on group labels' do @@ -105,7 +105,7 @@ describe Projects::LabelsController do toggle_subscription(group_label) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end def toggle_subscription(label) @@ -121,7 +121,7 @@ describe Projects::LabelsController do it 'denies access' do post :promote, namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -170,7 +170,7 @@ describe Projects::LabelsController do it 'does not redirect' do get :index, namespace_id: project.namespace, project_id: project.to_param - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -203,13 +203,13 @@ describe Projects::LabelsController do it 'does not 404' do post :generate, namespace_id: project.namespace, project_id: project - expect(response).not_to have_http_status(404) + expect(response).not_to have_gitlab_http_status(404) end it 'does not redirect to the correct casing' do post :generate, namespace_id: project.namespace, project_id: project - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -219,7 +219,7 @@ describe Projects::LabelsController do it 'returns not found' do post :generate, namespace_id: project.namespace, project_id: project.to_param + 'old' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/mattermosts_controller_spec.rb b/spec/controllers/projects/mattermosts_controller_spec.rb index 4eea7041d29..33d48ff94d1 100644 --- a/spec/controllers/projects/mattermosts_controller_spec.rb +++ b/spec/controllers/projects/mattermosts_controller_spec.rb @@ -20,7 +20,7 @@ describe Projects::MattermostsController do namespace_id: project.namespace.to_param, project_id: project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end diff --git a/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb b/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb index c6d50c28106..2d7647a6e12 100644 --- a/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb +++ b/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb @@ -28,7 +28,7 @@ describe Projects::MergeRequests::ConflictsController do end it 'returns a 200 status code' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end it 'returns JSON with a message' do @@ -116,7 +116,7 @@ describe Projects::MergeRequests::ConflictsController do end it 'returns a 404 status code' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -126,7 +126,7 @@ describe Projects::MergeRequests::ConflictsController do end it 'returns a 404 status code' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -138,7 +138,7 @@ describe Projects::MergeRequests::ConflictsController do end it 'returns a 200 status code' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end it 'returns the file in JSON format' do @@ -198,7 +198,7 @@ describe Projects::MergeRequests::ConflictsController do end it 'returns an OK response' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end @@ -224,7 +224,7 @@ describe Projects::MergeRequests::ConflictsController do end it 'returns a 400 error' do - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end it 'has a message with the name of the first missing section' do @@ -254,7 +254,7 @@ describe Projects::MergeRequests::ConflictsController do end it 'returns a 400 error' do - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end it 'has a message with the name of the missing file' do @@ -292,7 +292,7 @@ describe Projects::MergeRequests::ConflictsController do end it 'returns a 400 error' do - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end it 'has a message with the path of the problem file' do diff --git a/spec/controllers/projects/merge_requests/creations_controller_spec.rb b/spec/controllers/projects/merge_requests/creations_controller_spec.rb index fc4cec53374..7fdddc02fd3 100644 --- a/spec/controllers/projects/merge_requests/creations_controller_spec.rb +++ b/spec/controllers/projects/merge_requests/creations_controller_spec.rb @@ -112,7 +112,7 @@ describe Projects::MergeRequests::CreationsController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb index 7260350d5fb..18a70bec103 100644 --- a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb +++ b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb @@ -119,7 +119,7 @@ describe Projects::MergeRequests::DiffsController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -131,7 +131,7 @@ describe Projects::MergeRequests::DiffsController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -142,7 +142,7 @@ describe Projects::MergeRequests::DiffsController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -155,7 +155,7 @@ describe Projects::MergeRequests::DiffsController do end it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index 707e7c32283..b7cccddefdd 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -143,7 +143,7 @@ describe Projects::MergeRequestsController do get_merge_requests(last_page) expect(assigns(:merge_requests).current_page).to eq(last_page) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not redirect to external sites when provided a host field' do @@ -278,7 +278,7 @@ describe Projects::MergeRequestsController do end it 'returns 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -434,7 +434,7 @@ describe Projects::MergeRequestsController do it "denies access to users unless they're admin or project owner" do delete :destroy, namespace_id: project.namespace, project_id: project, id: merge_request.iid - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when the user is owner" do @@ -449,7 +449,7 @@ describe Projects::MergeRequestsController do it "deletes the merge request" do delete :destroy, namespace_id: project.namespace, project_id: project, id: merge_request.iid - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(controller).to set_flash[:notice].to(/The merge request was successfully deleted\./) end @@ -539,7 +539,7 @@ describe Projects::MergeRequestsController do subject end - it { is_expected.to have_http_status(:success) } + it { is_expected.to have_gitlab_http_status(:success) } it 'renders MergeRequest as JSON' do subject @@ -636,7 +636,7 @@ describe Projects::MergeRequestsController do end it 'return a detailed head_pipeline status in json' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['text']).to eq status.text expect(json_response['label']).to eq status.label expect(json_response['icon']).to eq status.icon @@ -650,7 +650,7 @@ describe Projects::MergeRequestsController do end it 'return empty' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_empty end end diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb index 62f1fb1f697..573530d0db0 100644 --- a/spec/controllers/projects/milestones_controller_spec.rb +++ b/spec/controllers/projects/milestones_controller_spec.rb @@ -27,7 +27,7 @@ describe Projects::MilestonesController do it 'shows milestone page' do view_milestone - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb index 135fd6449ff..1184c55e540 100644 --- a/spec/controllers/projects/notes_controller_spec.rb +++ b/spec/controllers/projects/notes_controller_spec.rb @@ -180,13 +180,13 @@ describe Projects::NotesController do it "returns status 302 for html" do post :create, request_params - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end it "returns status 200 for json" do post :create, request_params.merge(format: :json) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when merge_request_diff_head_sha present' do @@ -205,7 +205,7 @@ describe Projects::NotesController do it "returns status 302 for html" do post :create, request_params - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -240,7 +240,7 @@ describe Projects::NotesController do it 'returns a 404' do post_create(note_project_id: Project.maximum(:id).succ) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -248,7 +248,7 @@ describe Projects::NotesController do it 'returns a 404' do post_create - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -278,7 +278,7 @@ describe Projects::NotesController do request_params[:note][:noteable_id] = 9999 post :create, request_params.merge(format: :json) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -286,13 +286,13 @@ describe Projects::NotesController do it 'returns 302 status for html' do post :create, request_params - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end it 'returns 200 status for json' do post :create, request_params.merge(format: :json) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'creates a new note' do @@ -308,7 +308,7 @@ describe Projects::NotesController do it 'returns 404 status' do post :create, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not create a new note' do @@ -337,7 +337,7 @@ describe Projects::NotesController do it "returns status 200 for html" do delete :destroy, request_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "deletes the note" do @@ -354,7 +354,7 @@ describe Projects::NotesController do it "returns status 404" do delete :destroy, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -370,7 +370,7 @@ describe Projects::NotesController do post(:toggle_award_emoji, request_params.merge(name: "thumbsup")) end.to change { note.award_emoji.count }.by(1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "removes the already awarded emoji" do @@ -380,7 +380,7 @@ describe Projects::NotesController do post(:toggle_award_emoji, request_params.merge(name: "thumbsup")) end.to change { AwardEmoji.count }.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -398,7 +398,7 @@ describe Projects::NotesController do it "returns status 404" do post :resolve, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -415,7 +415,7 @@ describe Projects::NotesController do it "returns status 404" do post :resolve, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -442,7 +442,7 @@ describe Projects::NotesController do it "returns status 200" do post :resolve, request_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -459,7 +459,7 @@ describe Projects::NotesController do it "returns status 404" do delete :unresolve, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -476,7 +476,7 @@ describe Projects::NotesController do it "returns status 404" do delete :unresolve, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -490,7 +490,7 @@ describe Projects::NotesController do it "returns status 200" do delete :unresolve, request_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/projects/pages_controller_spec.rb b/spec/controllers/projects/pages_controller_spec.rb index 83c7744a231..4705c50de7e 100644 --- a/spec/controllers/projects/pages_controller_spec.rb +++ b/spec/controllers/projects/pages_controller_spec.rb @@ -21,7 +21,7 @@ describe Projects::PagesController do it 'returns 200 status' do get :show, request_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when the project is in a subgroup' do @@ -31,7 +31,7 @@ describe Projects::PagesController do it 'returns a 404 status code' do get :show, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -40,7 +40,7 @@ describe Projects::PagesController do it 'returns 302 status' do delete :destroy, request_params - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -53,7 +53,7 @@ describe Projects::PagesController do it 'returns 404 status' do get :show, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -61,7 +61,7 @@ describe Projects::PagesController do it 'returns 404 status' do delete :destroy, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/pages_domains_controller_spec.rb b/spec/controllers/projects/pages_domains_controller_spec.rb index ad4d7da3bdd..e9e7d357d9c 100644 --- a/spec/controllers/projects/pages_domains_controller_spec.rb +++ b/spec/controllers/projects/pages_domains_controller_spec.rb @@ -26,7 +26,7 @@ describe Projects::PagesDomainsController do it "displays the 'show' page" do get(:show, request_params.merge(id: pages_domain.domain)) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template('show') end end @@ -35,7 +35,7 @@ describe Projects::PagesDomainsController do it "displays the 'new' page" do get(:new, request_params) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template('new') end end @@ -69,7 +69,7 @@ describe Projects::PagesDomainsController do it 'returns 404 status' do get(:show, request_params.merge(id: pages_domain.domain)) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -77,7 +77,7 @@ describe Projects::PagesDomainsController do it 'returns 404 status' do get :new, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -85,7 +85,7 @@ describe Projects::PagesDomainsController do it "returns 404 status" do post(:create, request_params.merge(pages_domain: pages_domain_params)) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -93,7 +93,7 @@ describe Projects::PagesDomainsController do it "deletes the pages domain" do delete(:destroy, request_params.merge(id: pages_domain.domain)) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/pipeline_schedules_controller_spec.rb b/spec/controllers/projects/pipeline_schedules_controller_spec.rb index 4ac0559c679..4e52e261920 100644 --- a/spec/controllers/projects/pipeline_schedules_controller_spec.rb +++ b/spec/controllers/projects/pipeline_schedules_controller_spec.rb @@ -15,7 +15,7 @@ describe Projects::PipelineSchedulesController do it 'renders the index view' do visit_pipelines_schedules - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template(:index) end @@ -35,7 +35,7 @@ describe Projects::PipelineSchedulesController do end it 'only shows active pipeline schedules' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:schedules)).to include(pipeline_schedule) expect(assigns(:schedules)).not_to include(inactive_pipeline_schedule) end @@ -57,7 +57,7 @@ describe Projects::PipelineSchedulesController do it 'initializes a pipeline schedule model' do get :new, namespace_id: project.namespace.to_param, project_id: project - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:schedule)).to be_a_new(Ci::PipelineSchedule) end end @@ -87,7 +87,7 @@ describe Projects::PipelineSchedulesController do .to change { Ci::PipelineSchedule.count }.by(1) .and change { Ci::PipelineScheduleVariable.count }.by(1) - expect(response).to have_http_status(:found) + expect(response).to have_gitlab_http_status(:found) Ci::PipelineScheduleVariable.last.tap do |v| expect(v.key).to eq("AAA") @@ -158,7 +158,7 @@ describe Projects::PipelineSchedulesController do expect { go }.to change { Ci::PipelineScheduleVariable.count }.by(1) pipeline_schedule.reload - expect(response).to have_http_status(:found) + expect(response).to have_gitlab_http_status(:found) expect(pipeline_schedule.variables.last.key).to eq('AAA') expect(pipeline_schedule.variables.last.value).to eq('AAA123') end @@ -324,7 +324,7 @@ describe Projects::PipelineSchedulesController do it 'loads the pipeline schedule' do get :edit, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(assigns(:schedule)).to eq(pipeline_schedule) end end @@ -376,7 +376,7 @@ describe Projects::PipelineSchedulesController do end it 'does not delete the pipeline schedule' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -391,7 +391,7 @@ describe Projects::PipelineSchedulesController do delete :destroy, namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id end.to change { project.pipeline_schedules.count }.by(-1) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end end diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index 67b53d2acce..1604a2da485 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -33,7 +33,7 @@ describe Projects::PipelinesController do it 'returns JSON with serialized pipelines' do subject - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline') expect(json_response).to include('pipelines') @@ -46,7 +46,7 @@ describe Projects::PipelinesController do context 'when performing gitaly calls', :request_store do it 'limits the Gitaly requests' do - expect { subject }.to change { Gitlab::GitalyClient.get_request_count }.by(10) + expect { subject }.to change { Gitlab::GitalyClient.get_request_count }.by(8) end end end @@ -57,7 +57,7 @@ describe Projects::PipelinesController do it 'returns the pipeline' do get_pipeline_json - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).not_to be_an(Array) expect(json_response['id']).to be(pipeline.id) expect(json_response['details']).to have_key 'stages' @@ -111,7 +111,7 @@ describe Projects::PipelinesController do end it 'returns html source for stage dropdown' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to render_template('projects/pipelines/_stage') expect(json_response).to include('html') end @@ -123,7 +123,7 @@ describe Projects::PipelinesController do end it 'responds with not found' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -148,7 +148,7 @@ describe Projects::PipelinesController do end it 'return a detailed pipeline status in json' do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response['text']).to eq status.text expect(json_response['label']).to eq status.label expect(json_response['icon']).to eq status.icon @@ -171,14 +171,14 @@ describe Projects::PipelinesController do let(:feature) { ProjectFeature::ENABLED } it 'retries a pipeline without returning any content' do - expect(response).to have_http_status(:no_content) + expect(response).to have_gitlab_http_status(:no_content) expect(build.reload).to be_retried end end context 'when builds are disabled' do it 'fails to retry pipeline' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -198,14 +198,14 @@ describe Projects::PipelinesController do let(:feature) { ProjectFeature::ENABLED } it 'cancels a pipeline without returning any content' do - expect(response).to have_http_status(:no_content) + expect(response).to have_gitlab_http_status(:no_content) expect(pipeline.reload).to be_canceled end end context 'when builds are disabled' do it 'fails to retry pipeline' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/controllers/projects/pipelines_settings_controller_spec.rb b/spec/controllers/projects/pipelines_settings_controller_spec.rb index ee46ad00947..21b6a6d45f5 100644 --- a/spec/controllers/projects/pipelines_settings_controller_spec.rb +++ b/spec/controllers/projects/pipelines_settings_controller_spec.rb @@ -25,7 +25,7 @@ describe Projects::PipelinesSettingsController do let(:params) { { enabled: '', domain: 'mepmep.md' } } it 'redirects to the settings page' do - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(flash[:notice]).to eq("Pipelines settings for '#{project.name}' were successfully updated.") end diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb index 3cb1bec5ea2..a34dc27a5ed 100644 --- a/spec/controllers/projects/project_members_controller_spec.rb +++ b/spec/controllers/projects/project_members_controller_spec.rb @@ -8,7 +8,7 @@ describe Projects::ProjectMembersController do it 'should have the project_members address with a 200 status code' do get :index, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -30,7 +30,7 @@ describe Projects::ProjectMembersController do user_ids: project_user.id, access_level: Gitlab::Access::GUEST - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(project.users).not_to include project_user end end @@ -79,7 +79,7 @@ describe Projects::ProjectMembersController do project_id: project, id: 42 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -94,7 +94,7 @@ describe Projects::ProjectMembersController do project_id: project, id: member - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(project.members).to include member end end @@ -137,7 +137,7 @@ describe Projects::ProjectMembersController do delete :leave, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -168,7 +168,7 @@ describe Projects::ProjectMembersController do delete :leave, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -221,7 +221,7 @@ describe Projects::ProjectMembersController do project_id: project, id: 42 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -236,7 +236,7 @@ describe Projects::ProjectMembersController do project_id: project, id: member - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(project.members).not_to include member end end diff --git a/spec/controllers/projects/prometheus_controller_spec.rb b/spec/controllers/projects/prometheus_controller_spec.rb index 8407a53272a..bbfe78d305a 100644 --- a/spec/controllers/projects/prometheus_controller_spec.rb +++ b/spec/controllers/projects/prometheus_controller_spec.rb @@ -24,7 +24,7 @@ describe Projects::PrometheusController do it 'returns no content response' do get :active_metrics, project_params(format: :json) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end end @@ -38,7 +38,7 @@ describe Projects::PrometheusController do it 'returns no content response' do get :active_metrics, project_params(format: :json) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq(sample_response.deep_stringify_keys) end end @@ -47,7 +47,7 @@ describe Projects::PrometheusController do it 'returns not found response' do get :active_metrics, project_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb index b4eaab29fed..3a0c3faa7b4 100644 --- a/spec/controllers/projects/raw_controller_spec.rb +++ b/spec/controllers/projects/raw_controller_spec.rb @@ -13,7 +13,7 @@ describe Projects::RawController do project_id: public_project, id: id) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') expect(response.header['Content-Disposition']) .to eq('inline') @@ -30,7 +30,7 @@ describe Projects::RawController do project_id: public_project, id: id) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.header['Content-Type']).to eq('image/jpeg') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') end @@ -59,7 +59,7 @@ describe Projects::RawController do project_id: public_project, id: id) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -70,7 +70,7 @@ describe Projects::RawController do project_id: public_project, id: id) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -86,7 +86,7 @@ describe Projects::RawController do project_id: public_project, id: id) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') expect(response.header['Content-Disposition']) .to eq('inline') diff --git a/spec/controllers/projects/registry/repositories_controller_spec.rb b/spec/controllers/projects/registry/repositories_controller_spec.rb index 5d9d5351687..17769a14def 100644 --- a/spec/controllers/projects/registry/repositories_controller_spec.rb +++ b/spec/controllers/projects/registry/repositories_controller_spec.rb @@ -35,7 +35,7 @@ describe Projects::Registry::RepositoriesController do it 'successfully renders container repositories' do go_to_index - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end it 'creates a root container repository' do @@ -46,7 +46,7 @@ describe Projects::Registry::RepositoriesController do it 'json has a list of projects' do go_to_index(format: :json) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('registry/repositories') end end @@ -59,7 +59,7 @@ describe Projects::Registry::RepositoriesController do it 'successfully renders container repositories' do go_to_index - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end it 'does not ensure root container repository' do @@ -69,7 +69,7 @@ describe Projects::Registry::RepositoriesController do it 'responds with json if asked' do go_to_index(format: :json) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(json_response).to be_kind_of(Array) end end @@ -89,7 +89,7 @@ describe Projects::Registry::RepositoriesController do it 'deletes a repository' do expect { delete_repository(repository) }.to change { ContainerRepository.all.count }.by(-1) - expect(response).to have_http_status(:no_content) + expect(response).to have_gitlab_http_status(:no_content) end end end @@ -100,7 +100,7 @@ describe Projects::Registry::RepositoriesController do it 'responds with 404' do go_to_index - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end it 'does not ensure root container repository' do diff --git a/spec/controllers/projects/registry/tags_controller_spec.rb b/spec/controllers/projects/registry/tags_controller_spec.rb index bb702ebeb23..7fee8fd44ff 100644 --- a/spec/controllers/projects/registry/tags_controller_spec.rb +++ b/spec/controllers/projects/registry/tags_controller_spec.rb @@ -30,7 +30,7 @@ describe Projects::Registry::TagsController do it 'receive a list of tags' do get_tags - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('registry/tags') expect(response).to include_pagination_headers end @@ -44,7 +44,7 @@ describe Projects::Registry::TagsController do it 'receive a list of tags' do get_tags - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('registry/tags') expect(response).to include_pagination_headers end @@ -58,7 +58,7 @@ describe Projects::Registry::TagsController do it 'does not receive a list of tags' do get_tags - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/projects/repositories_controller_spec.rb b/spec/controllers/projects/repositories_controller_spec.rb index f712d1e0d63..8b777eb68ca 100644 --- a/spec/controllers/projects/repositories_controller_spec.rb +++ b/spec/controllers/projects/repositories_controller_spec.rb @@ -35,7 +35,7 @@ describe Projects::RepositoriesController do it "renders Not Found" do get :archive, namespace_id: project.namespace, project_id: project, ref: "master", format: "zip" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/runners_controller_spec.rb b/spec/controllers/projects/runners_controller_spec.rb index 2b6f988fd9c..89a13f3c976 100644 --- a/spec/controllers/projects/runners_controller_spec.rb +++ b/spec/controllers/projects/runners_controller_spec.rb @@ -29,7 +29,7 @@ describe Projects::RunnersController do runner.reload - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(runner.description).to eq(new_desc) end end @@ -38,7 +38,7 @@ describe Projects::RunnersController do it 'destroys the runner' do delete :destroy, params - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(Ci::Runner.find_by(id: runner.id)).to be_nil end end @@ -53,7 +53,7 @@ describe Projects::RunnersController do runner.reload - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(runner.active).to eq(true) end end @@ -68,7 +68,7 @@ describe Projects::RunnersController do runner.reload - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(runner.active).to eq(false) end end diff --git a/spec/controllers/projects/services_controller_spec.rb b/spec/controllers/projects/services_controller_spec.rb index efba9cc7306..a907da2b60f 100644 --- a/spec/controllers/projects/services_controller_spec.rb +++ b/spec/controllers/projects/services_controller_spec.rb @@ -19,7 +19,7 @@ describe Projects::ServicesController do put :test, namespace_id: project.namespace, project_id: project, id: service.to_param - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/controllers/projects/settings/ci_cd_controller_spec.rb b/spec/controllers/projects/settings/ci_cd_controller_spec.rb index a8f4b79b64c..b8fe0f46f57 100644 --- a/spec/controllers/projects/settings/ci_cd_controller_spec.rb +++ b/spec/controllers/projects/settings/ci_cd_controller_spec.rb @@ -13,7 +13,7 @@ describe Projects::Settings::CiCdController do it 'renders show with 200 status code' do get :show, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template(:show) end end diff --git a/spec/controllers/projects/settings/integrations_controller_spec.rb b/spec/controllers/projects/settings/integrations_controller_spec.rb index e0f9a5b24a6..3068837f394 100644 --- a/spec/controllers/projects/settings/integrations_controller_spec.rb +++ b/spec/controllers/projects/settings/integrations_controller_spec.rb @@ -13,7 +13,7 @@ describe Projects::Settings::IntegrationsController do it 'renders show with 200 status code' do get :show, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template(:show) end end diff --git a/spec/controllers/projects/settings/repository_controller_spec.rb b/spec/controllers/projects/settings/repository_controller_spec.rb index f73471f8ca8..3a4014b7768 100644 --- a/spec/controllers/projects/settings/repository_controller_spec.rb +++ b/spec/controllers/projects/settings/repository_controller_spec.rb @@ -13,7 +13,7 @@ describe Projects::Settings::RepositoryController do it 'renders show with 200 status code' do get :show, namespace_id: project.namespace, project_id: project - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template(:show) end end diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb index 3a1550aa730..e7c0b484ede 100644 --- a/spec/controllers/projects/snippets_controller_spec.rb +++ b/spec/controllers/projects/snippets_controller_spec.rb @@ -29,7 +29,7 @@ describe Projects::SnippetsController do project_id: project, page: last_page.to_param expect(assigns(:snippets).current_page).to eq(last_page) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -41,7 +41,7 @@ describe Projects::SnippetsController do get :index, namespace_id: project.namespace, project_id: project expect(assigns(:snippets)).not_to include(project_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -54,7 +54,7 @@ describe Projects::SnippetsController do get :index, namespace_id: project.namespace, project_id: project expect(assigns(:snippets)).to include(project_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -67,7 +67,7 @@ describe Projects::SnippetsController do get :index, namespace_id: project.namespace, project_id: project expect(assigns(:snippets)).to include(project_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -316,7 +316,7 @@ describe Projects::SnippetsController do it 'responds with status 404' do get action, namespace_id: project.namespace, project_id: project, id: project_snippet.to_param - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -329,7 +329,7 @@ describe Projects::SnippetsController do get action, namespace_id: project.namespace, project_id: project, id: project_snippet.to_param expect(assigns(:snippet)).to eq(project_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -342,7 +342,7 @@ describe Projects::SnippetsController do get action, namespace_id: project.namespace, project_id: project, id: project_snippet.to_param expect(assigns(:snippet)).to eq(project_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -352,7 +352,7 @@ describe Projects::SnippetsController do it 'responds with status 404' do get action, namespace_id: project.namespace, project_id: project, id: 42 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -364,7 +364,7 @@ describe Projects::SnippetsController do it 'responds with status 404' do get action, namespace_id: project.namespace, project_id: project, id: 42 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/todos_controller_spec.rb b/spec/controllers/projects/todos_controller_spec.rb index 41d211ed1bb..4622e27e60f 100644 --- a/spec/controllers/projects/todos_controller_spec.rb +++ b/spec/controllers/projects/todos_controller_spec.rb @@ -28,13 +28,13 @@ describe Projects::TodosController do go end.to change { user.todos.count }.by(1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns todo path and pending count' do go - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['count']).to eq 1 expect(json_response['delete_path']).to match(/\/dashboard\/todos\/\d{1}/) end @@ -47,7 +47,7 @@ describe Projects::TodosController do go end.to change { user.todos.count }.by(0) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not create todo for issue when user not logged in' do @@ -55,7 +55,7 @@ describe Projects::TodosController do go end.to change { user.todos.count }.by(0) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -68,7 +68,7 @@ describe Projects::TodosController do it "doesn't create todo" do expect { go }.not_to change { user.todos.count } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -96,13 +96,13 @@ describe Projects::TodosController do go end.to change { user.todos.count }.by(1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns todo path and pending count' do go - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['count']).to eq 1 expect(json_response['delete_path']).to match(/\/dashboard\/todos\/\d{1}/) end @@ -115,7 +115,7 @@ describe Projects::TodosController do go end.to change { user.todos.count }.by(0) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not create todo for merge request user has no access to' do @@ -123,7 +123,7 @@ describe Projects::TodosController do go end.to change { user.todos.count }.by(0) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -136,7 +136,7 @@ describe Projects::TodosController do it "doesn't create todo" do expect { go }.not_to change { user.todos.count } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb index 775f3998f5d..65b821c9486 100644 --- a/spec/controllers/projects/tree_controller_spec.rb +++ b/spec/controllers/projects/tree_controller_spec.rb @@ -64,7 +64,7 @@ describe Projects::TreeController do context "valid SHA commit ID with path" do let(:id) { '6d39438/.gitignore' } - it { expect(response).to have_http_status(302) } + it { expect(response).to have_gitlab_http_status(302) } end end diff --git a/spec/controllers/projects/uploads_controller_spec.rb b/spec/controllers/projects/uploads_controller_spec.rb index 488bcf31371..c2550b1efa7 100644 --- a/spec/controllers/projects/uploads_controller_spec.rb +++ b/spec/controllers/projects/uploads_controller_spec.rb @@ -18,7 +18,7 @@ describe Projects::UploadsController do namespace_id: project.namespace.to_param, project_id: project, format: :json - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -90,7 +90,7 @@ describe Projects::UploadsController do it "responds with status 200" do go - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -98,7 +98,7 @@ describe Projects::UploadsController do it "responds with status 404" do go - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -117,7 +117,7 @@ describe Projects::UploadsController do it "responds with status 200" do go - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -125,7 +125,7 @@ describe Projects::UploadsController do it "responds with status 404" do go - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -151,7 +151,7 @@ describe Projects::UploadsController do it "responds with status 200" do go - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -192,7 +192,7 @@ describe Projects::UploadsController do it "responds with status 200" do go - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -200,7 +200,7 @@ describe Projects::UploadsController do it "responds with status 404" do go - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -220,7 +220,7 @@ describe Projects::UploadsController do it "responds with status 200" do go - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -228,7 +228,7 @@ describe Projects::UploadsController do it "responds with status 404" do go - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -237,7 +237,7 @@ describe Projects::UploadsController do it "responds with status 404" do go - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/projects/variables_controller_spec.rb b/spec/controllers/projects/variables_controller_spec.rb index 6957fb43c19..d065cd00d00 100644 --- a/spec/controllers/projects/variables_controller_spec.rb +++ b/spec/controllers/projects/variables_controller_spec.rb @@ -50,7 +50,7 @@ describe Projects::VariablesController do post :update, namespace_id: project.namespace.to_param, project_id: project, id: variable.id, variable: { key: '?', value: variable.value } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template :show end end diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 7569052c3aa..b1d7157e447 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -24,7 +24,7 @@ describe ProjectsController do get :new, namespace_id: group.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template('new') end end @@ -33,7 +33,7 @@ describe ProjectsController do it 'responds with status 404' do get :new, namespace_id: group.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(response).not_to render_template('new') end end @@ -152,7 +152,7 @@ describe ProjectsController do it 'renders a 503' do get :show, namespace_id: project.namespace, id: project - expect(response).to have_http_status(503) + expect(response).to have_gitlab_http_status(503) end end @@ -257,7 +257,7 @@ describe ProjectsController do get :show, namespace_id: project.namespace, id: project, format: :git - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(response).to redirect_to(namespace_project_path) end end @@ -280,7 +280,7 @@ describe ProjectsController do expect(project.path).to include 'renamed_path' expect(assigns(:repository).path).to include project.path - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -296,7 +296,7 @@ describe ProjectsController do .not_to change { project.reload.path } expect(controller).to set_flash[:alert].to(/container registry tags/) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -312,7 +312,7 @@ describe ProjectsController do id: project.id, project: params - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) params.each do |param, value| expect(project.public_send(param)).to eq(value) end @@ -345,7 +345,7 @@ describe ProjectsController do project.reload expect(project.namespace).to eq(new_namespace) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when new namespace is empty' do @@ -364,7 +364,7 @@ describe ProjectsController do project.reload expect(project.namespace).to eq(old_namespace) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(flash[:alert]).to eq 'Please select a new namespace for your project.' end end @@ -381,7 +381,7 @@ describe ProjectsController do delete :destroy, namespace_id: project.namespace, id: project expect { Project.find(orig_id) }.to raise_error(ActiveRecord::RecordNotFound) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(response).to redirect_to(dashboard_projects_path) end @@ -420,7 +420,7 @@ describe ProjectsController do end it 'has http status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'changes the user incoming email token' do @@ -496,7 +496,7 @@ describe ProjectsController do delete(:remove_fork, namespace_id: project.namespace, id: project, format: :js) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -544,7 +544,7 @@ describe ProjectsController do get :show, namespace_id: public_project.namespace, id: public_project expect(assigns(:project)).to eq(public_project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -583,13 +583,13 @@ describe ProjectsController do it 'does not 404' do post :toggle_star, namespace_id: public_project.namespace, id: public_project.path.upcase - expect(response).not_to have_http_status(404) + expect(response).not_to have_gitlab_http_status(404) end it 'does not redirect to the correct casing' do post :toggle_star, namespace_id: public_project.namespace, id: public_project.path.upcase - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -599,7 +599,7 @@ describe ProjectsController do it 'returns not found' do post :toggle_star, namespace_id: 'foo', id: 'bar' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -613,13 +613,13 @@ describe ProjectsController do it 'does not 404' do delete :destroy, namespace_id: project.namespace, id: project.path.upcase - expect(response).not_to have_http_status(404) + expect(response).not_to have_gitlab_http_status(404) end it 'does not redirect to the correct casing' do delete :destroy, namespace_id: project.namespace, id: project.path.upcase - expect(response).not_to have_http_status(301) + expect(response).not_to have_gitlab_http_status(301) end end @@ -629,7 +629,7 @@ describe ProjectsController do it 'returns not found' do delete :destroy, namespace_id: 'foo', id: 'bar' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -646,7 +646,7 @@ describe ProjectsController do it 'returns 302' do get :export, namespace_id: project.namespace, id: project - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -658,7 +658,7 @@ describe ProjectsController do it 'returns 404' do get :export, namespace_id: project.namespace, id: project - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -674,7 +674,7 @@ describe ProjectsController do it 'returns 302' do get :download_export, namespace_id: project.namespace, id: project - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -686,7 +686,7 @@ describe ProjectsController do it 'returns 404' do get :download_export, namespace_id: project.namespace, id: project - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -702,7 +702,7 @@ describe ProjectsController do it 'returns 302' do post :remove_export, namespace_id: project.namespace, id: project - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -714,7 +714,7 @@ describe ProjectsController do it 'returns 404' do post :remove_export, namespace_id: project.namespace, id: project - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -730,7 +730,7 @@ describe ProjectsController do it 'returns 302' do post :generate_new_export, namespace_id: project.namespace, id: project - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) end end @@ -742,7 +742,7 @@ describe ProjectsController do it 'returns 404' do post :generate_new_export, namespace_id: project.namespace, id: project - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb index 31593ce7311..54a9af92f07 100644 --- a/spec/controllers/sent_notifications_controller_spec.rb +++ b/spec/controllers/sent_notifications_controller_spec.rb @@ -69,7 +69,7 @@ describe SentNotificationsController do end it 'returns a 404' do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index a22fd8eaf9b..55bd4352bd3 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -19,7 +19,7 @@ describe SessionsController do it 'redirects to :omniauth_authorize_path' do get(:new) - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(response).to redirect_to('/saml') end end @@ -28,7 +28,7 @@ describe SessionsController do it 'responds with 200' do get(:new, auto_sign_in: 'false') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/snippets/notes_controller_spec.rb b/spec/controllers/snippets/notes_controller_spec.rb index 225753333ee..e6148ea1734 100644 --- a/spec/controllers/snippets/notes_controller_spec.rb +++ b/spec/controllers/snippets/notes_controller_spec.rb @@ -20,7 +20,7 @@ describe Snippets::NotesController do end it "returns status 200" do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns not empty array of notes" do @@ -37,7 +37,7 @@ describe Snippets::NotesController do it "returns status 404" do get :index, { snippet_id: internal_snippet } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -49,7 +49,7 @@ describe Snippets::NotesController do it "returns status 200" do get :index, { snippet_id: internal_snippet } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -63,7 +63,7 @@ describe Snippets::NotesController do it "returns status 404" do get :index, { snippet_id: private_snippet } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -75,7 +75,7 @@ describe Snippets::NotesController do it "returns status 404" do get :index, { snippet_id: private_snippet } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -89,7 +89,7 @@ describe Snippets::NotesController do it "returns status 200" do get :index, { snippet_id: private_snippet } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns 1 note" do @@ -134,7 +134,7 @@ describe Snippets::NotesController do it "returns status 200" do delete :destroy, request_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "deletes the note" do @@ -162,7 +162,7 @@ describe Snippets::NotesController do it "returns status 404" do delete :destroy, request_params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not update the note" do @@ -182,7 +182,7 @@ describe Snippets::NotesController do it "toggles the award emoji" do expect { subject }.to change { note.award_emoji.count }.by(1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "removes the already awarded emoji when it exists" do @@ -190,7 +190,7 @@ describe Snippets::NotesController do expect { subject }.to change { AwardEmoji.count }.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index be273acb69b..9effe47ab05 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -40,7 +40,7 @@ describe SnippetsController do it 'responds with status 200' do get :new - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -69,7 +69,7 @@ describe SnippetsController do it 'responds with status 404' do get :show, id: other_personal_snippet.to_param - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -78,7 +78,7 @@ describe SnippetsController do get :show, id: personal_snippet.to_param expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -104,7 +104,7 @@ describe SnippetsController do get :show, id: personal_snippet.to_param expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -129,7 +129,7 @@ describe SnippetsController do get :show, id: personal_snippet.to_param expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -138,7 +138,7 @@ describe SnippetsController do get :show, id: personal_snippet.to_param expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -152,7 +152,7 @@ describe SnippetsController do it 'responds with status 404' do get :show, id: 'doesntexist' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -432,7 +432,7 @@ describe SnippetsController do it 'responds with status 404' do get :raw, id: other_personal_snippet.to_param - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -443,7 +443,7 @@ describe SnippetsController do it 'responds with status 200' do expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'has expected headers' do @@ -475,7 +475,7 @@ describe SnippetsController do get :raw, id: personal_snippet.to_param expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -500,7 +500,7 @@ describe SnippetsController do get :raw, id: personal_snippet.to_param expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'CRLF line ending' do @@ -527,7 +527,7 @@ describe SnippetsController do get :raw, id: personal_snippet.to_param expect(assigns(:snippet)).to eq(personal_snippet) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -541,7 +541,7 @@ describe SnippetsController do it 'responds with status 404' do get :raw, id: 'doesntexist' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb index b29f3d861be..7e42e43345c 100644 --- a/spec/controllers/uploads_controller_spec.rb +++ b/spec/controllers/uploads_controller_spec.rb @@ -18,7 +18,7 @@ describe UploadsController do it "returns 401 when the user is not logged in" do post :create, model: model, id: snippet.id, format: :json - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns 404 when user can't comment on a snippet" do @@ -27,7 +27,7 @@ describe UploadsController do sign_in(user) post :create, model: model, id: private_snippet.id, format: :json - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -39,7 +39,7 @@ describe UploadsController do it "returns an error without file" do post :create, model: model, id: snippet.id, format: :json - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end it "returns an error with invalid model" do @@ -50,7 +50,7 @@ describe UploadsController do it "returns 404 status when object not found" do post :create, model: model, id: 9999, format: :json - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'with valid image' do @@ -174,7 +174,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "user", mounted_as: "avatar", id: user.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -190,7 +190,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "user", mounted_as: "avatar", id: user.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -214,7 +214,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -233,7 +233,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -285,7 +285,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -301,7 +301,7 @@ describe UploadsController do it "responds with status 404" do get :show, model: "project", mounted_as: "avatar", id: project.id, filename: "image.png" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -316,7 +316,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -335,7 +335,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -378,7 +378,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -394,7 +394,7 @@ describe UploadsController do it "responds with status 404" do get :show, model: "group", mounted_as: "avatar", id: group.id, filename: "image.png" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -414,7 +414,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -433,7 +433,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -485,7 +485,7 @@ describe UploadsController do it "responds with status 200" do get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -501,7 +501,7 @@ describe UploadsController do it "responds with status 404" do get :show, model: "note", mounted_as: "attachment", id: note.id, filename: "image.png" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -516,7 +516,7 @@ describe UploadsController do it 'responds with status 200' do get :show, model: 'appearance', mounted_as: 'header_logo', id: appearance.id, filename: 'dk.png' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do @@ -535,7 +535,7 @@ describe UploadsController do it 'responds with status 200' do get :show, model: 'appearance', mounted_as: 'logo', id: appearance.id, filename: 'dk.png' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it_behaves_like 'content not cached without revalidation' do diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index 2cecd2646fc..01ab59aa363 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -24,7 +24,7 @@ describe UsersController do it 'renders the show template' do get :show, username: user.username - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template('show') end end @@ -49,7 +49,7 @@ describe UsersController do it 'renders show' do get :show, username: user.username - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template('show') end end @@ -70,7 +70,7 @@ describe UsersController do it 'renders 404' do get :show, username: 'nonexistent' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -82,7 +82,7 @@ describe UsersController do get :calendar, username: user.username, format: :json - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'forked project' do @@ -139,7 +139,7 @@ describe UsersController do context 'format html' do it 'renders snippets page' do get :snippets, username: user.username - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to render_template('show') end end @@ -147,7 +147,7 @@ describe UsersController do context 'format json' do it 'response with snippets json data' do get :snippets, username: user.username, format: :json - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(JSON.parse(response.body)).to have_key('html') end end diff --git a/spec/factories/instance_configuration.rb b/spec/factories/instance_configuration.rb new file mode 100644 index 00000000000..406c7c3caf1 --- /dev/null +++ b/spec/factories/instance_configuration.rb @@ -0,0 +1,5 @@ +FactoryGirl.define do + factory :instance_configuration do + skip_create + end +end diff --git a/spec/factories/services.rb b/spec/factories/services.rb index c2674ce2d11..ccf63f3ffa4 100644 --- a/spec/factories/services.rb +++ b/spec/factories/services.rb @@ -38,6 +38,8 @@ FactoryGirl.define do active true properties( url: 'https://jira.example.com', + username: 'jira_user', + password: 'my-secret-password', project_key: 'jira-key' ) end diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 8ce470fc288..2db6f9a2982 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -218,15 +218,54 @@ describe 'New/edit issue', :js do context 'edit issue' do before do - visit project_issue_path(project, issue) - page.within('.content .issuable-actions') do - click_on 'Edit' + visit edit_project_issue_path(project, issue) + end + + it 'allows user to update issue' do + expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match(user.id.to_s) + expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s) + expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible + + page.within '.js-user-search' do + expect(page).to have_content user.name + end + + page.within '.js-milestone-select' do + expect(page).to have_content milestone.title + end + + click_button 'Labels' + page.within '.dropdown-menu-labels' do + click_link label.title + click_link label2.title + end + page.within '.js-label-select' do + expect(page).to have_content label.title + end + expect(page.all('input[name="issue[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s) + expect(page.all('input[name="issue[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s) + + click_button 'Save changes' + + page.within '.issuable-sidebar' do + page.within '.assignee' do + expect(page).to have_content user.name + end + + page.within '.milestone' do + expect(page).to have_content milestone.title + end + + page.within '.labels' do + expect(page).to have_content label.title + expect(page).to have_content label2.title + end end end it 'description has autocomplete' do - find_field('issue-description').native.send_keys('') - fill_in 'issue-description', with: '@' + find('#issue_description').native.send_keys('') + fill_in 'issue_description', with: '@' expect(page).to have_selector('.atwho-view') end diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index cd97dd18c00..b6da66ea901 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Issues', :js do +describe 'Issues' do include DropzoneHelper include IssueHelpers include SortingHelper @@ -24,15 +24,109 @@ describe 'Issues', :js do end before do - visit project_issue_path(project, issue) - page.within('.content .issuable-actions') do - find('.issuable-edit').click - end - find('.issue-details .content-block .js-zen-enter').click + visit edit_project_issue_path(project, issue) + find('.js-zen-enter').click end it 'opens new issue popup' do - expect(page).to have_content(issue.description) + expect(page).to have_content("Issue ##{issue.iid}") + end + end + + describe 'Editing issue assignee' do + let!(:issue) do + create(:issue, + author: user, + assignees: [user], + project: project) + end + + it 'allows user to select unassigned', :js do + visit edit_project_issue_path(project, issue) + + expect(page).to have_content "Assignee #{user.name}" + + first('.js-user-search').click + click_link 'Unassigned' + + click_button 'Save changes' + + page.within('.assignee') do + expect(page).to have_content 'No assignee - assign yourself' + end + + expect(issue.reload.assignees).to be_empty + end + end + + describe 'due date', :js do + context 'on new form' do + before do + visit new_project_issue_path(project) + end + + it 'saves with due date' do + date = Date.today.at_beginning_of_month + + fill_in 'issue_title', with: 'bug 345' + fill_in 'issue_description', with: 'bug description' + find('#issuable-due-date').click + + page.within '.pika-single' do + click_button date.day + end + + expect(find('#issuable-due-date').value).to eq date.to_s + + click_button 'Submit issue' + + page.within '.issuable-sidebar' do + expect(page).to have_content date.to_s(:medium) + end + end + end + + context 'on edit form' do + let(:issue) { create(:issue, author: user, project: project, due_date: Date.today.at_beginning_of_month.to_s) } + + before do + visit edit_project_issue_path(project, issue) + end + + it 'saves with due date' do + date = Date.today.at_beginning_of_month + + expect(find('#issuable-due-date').value).to eq date.to_s + + date = date.tomorrow + + fill_in 'issue_title', with: 'bug 345' + fill_in 'issue_description', with: 'bug description' + find('#issuable-due-date').click + + page.within '.pika-single' do + click_button date.day + end + + expect(find('#issuable-due-date').value).to eq date.to_s + + click_button 'Save changes' + + page.within '.issuable-sidebar' do + expect(page).to have_content date.to_s(:medium) + end + end + + it 'warns about version conflict' do + issue.update(title: "New title") + + fill_in 'issue_title', with: 'bug 345' + fill_in 'issue_description', with: 'bug description' + + click_button 'Save changes' + + expect(page).to have_content 'Someone edited the issue the same time you did' + end end end diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb index d03ddfece74..ca2225318cd 100644 --- a/spec/features/merge_requests/created_from_fork_spec.rb +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -83,7 +83,6 @@ feature 'Merge request created from fork' do page.within('.merge-request-tabs') { click_link 'Pipelines' } page.within('.ci-table') do - expect(page).to have_content pipeline.status expect(page).to have_content pipeline.id end end diff --git a/spec/features/profiles/chat_names_spec.rb b/spec/features/profiles/chat_names_spec.rb index 35793539e0e..5c959acbbc9 100644 --- a/spec/features/profiles/chat_names_spec.rb +++ b/spec/features/profiles/chat_names_spec.rb @@ -33,7 +33,7 @@ feature 'Profile > Chat' do scenario 'second use of link is denied' do visit authorize_path - expect(page).to have_http_status(:not_found) + expect(page).to have_gitlab_http_status(:not_found) end end @@ -51,7 +51,7 @@ feature 'Profile > Chat' do scenario 'second use of link is denied' do visit authorize_path - expect(page).to have_http_status(:not_found) + expect(page).to have_gitlab_http_status(:not_found) end end end diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb index 225d4c16841..fb4355074df 100644 --- a/spec/features/profiles/password_spec.rb +++ b/spec/features/profiles/password_spec.rb @@ -58,7 +58,7 @@ describe 'Profile > Password' do visit edit_profile_password_path - expect(page).to have_http_status(200) + expect(page).to have_gitlab_http_status(200) end end @@ -68,7 +68,7 @@ describe 'Profile > Password' do it 'renders 404' do visit edit_profile_password_path - expect(page).to have_http_status(404) + expect(page).to have_gitlab_http_status(404) end end end diff --git a/spec/features/projects/badges/coverage_spec.rb b/spec/features/projects/badges/coverage_spec.rb index 368a046f741..c68e10a2563 100644 --- a/spec/features/projects/badges/coverage_spec.rb +++ b/spec/features/projects/badges/coverage_spec.rb @@ -50,7 +50,7 @@ feature 'test coverage badge' do scenario 'user requests test coverage badge image' do show_test_coverage_badge - expect(page).to have_http_status(404) + expect(page).to have_gitlab_http_status(404) end end diff --git a/spec/features/projects/commit/builds_spec.rb b/spec/features/projects/commit/builds_spec.rb index 9c57626ea1d..79e84a4f0a6 100644 --- a/spec/features/projects/commit/builds_spec.rb +++ b/spec/features/projects/commit/builds_spec.rb @@ -20,7 +20,6 @@ feature 'project commit pipelines', :js do visit pipelines_project_commit_path(project, project.commit.sha) page.within('.table-holder') do - expect(page).to have_content project.pipelines[0].status # pipeline status expect(page).to have_content project.pipelines[0].id # pipeline ids end end diff --git a/spec/features/projects/members/share_with_group_spec.rb b/spec/features/projects/members/share_with_group_spec.rb index a52fc316474..3198798306c 100644 --- a/spec/features/projects/members/share_with_group_spec.rb +++ b/spec/features/projects/members/share_with_group_spec.rb @@ -149,7 +149,7 @@ feature 'Project > Members > Share with Group', :js do create(:group).add_owner(master) visit project_settings_members_path(project) - execute_script 'GroupsSelect.PER_PAGE = 1;' + execute_script 'GROUP_SELECT_PER_PAGE = 1;' open_select2 '#link_group_id' end diff --git a/spec/features/projects/ref_switcher_spec.rb b/spec/features/projects/ref_switcher_spec.rb index f8695403857..50c0bfd580d 100644 --- a/spec/features/projects/ref_switcher_spec.rb +++ b/spec/features/projects/ref_switcher_spec.rb @@ -6,6 +6,7 @@ feature 'Ref switcher', :js do before do project.team << [user, :master] + page.driver.set_cookie('new_repo', 'true') sign_in(user) visit project_tree_path(project, 'master') end @@ -40,4 +41,38 @@ feature 'Ref switcher', :js do expect(page).to have_title "'test'" end + + context "create branch" do + let(:input) { find('.js-new-branch-name') } + + before do + click_button 'master' + wait_for_requests + + page.within '.project-refs-form' do + find(".dropdown-footer-list a").click + end + end + + it "shows error message for the invalid branch name" do + input.set 'foo bar' + click_button('Create') + wait_for_requests + expect(page).to have_content 'Branch name is invalid' + end + + it "should create new branch properly" do + input.set 'new-branch-name' + click_button('Create') + wait_for_requests + expect(find('.js-project-refs-dropdown')).to have_content 'new-branch-name' + end + + it "should create new branch by Enter key" do + input.set 'new-branch-name-2' + input.native.send_keys :enter + wait_for_requests + expect(find('.js-project-refs-dropdown')).to have_content 'new-branch-name-2' + end + end end diff --git a/spec/features/projects/tree/create_directory_spec.rb b/spec/features/projects/tree/create_directory_spec.rb new file mode 100644 index 00000000000..4c1fa5a666e --- /dev/null +++ b/spec/features/projects/tree/create_directory_spec.rb @@ -0,0 +1,43 @@ +require 'spec_helper' + +feature 'Multi-file editor new directory', :js do + include WaitForRequests + + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + + before do + project.add_master(user) + sign_in(user) + + page.driver.set_cookie('new_repo', 'true') + + visit project_tree_path(project, :master) + + wait_for_requests + end + + it 'creates directory in current directory' do + find('.add-to-tree').click + + click_link('New directory') + + page.within('.popup-dialog') do + find('.form-control').set('foldername') + + click_button('Create directory') + end + + fill_in('commit-message', with: 'commit message') + + click_button('Commit 1 file') + + expect(page).to have_content('Your changes have been committed') + expect(page).to have_selector('td', text: 'commit message') + + click_link('foldername') + + expect(page).to have_selector('td', text: 'commit message', count: 2) + expect(page).to have_selector('td', text: '.gitkeep') + end +end diff --git a/spec/features/projects/tree/create_file_spec.rb b/spec/features/projects/tree/create_file_spec.rb new file mode 100644 index 00000000000..a67ec891e7c --- /dev/null +++ b/spec/features/projects/tree/create_file_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +feature 'Multi-file editor new file', :js do + include WaitForRequests + + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } + + before do + project.add_master(user) + sign_in(user) + + page.driver.set_cookie('new_repo', 'true') + + visit project_tree_path(project, :master) + + wait_for_requests + end + + it 'creates file in current directory' do + find('.add-to-tree').click + + click_link('New file') + + page.within('.popup-dialog') do + find('.form-control').set('filename') + + click_button('Create file') + end + + find('.inputarea').send_keys('file content') + + fill_in('commit-message', with: 'commit message') + + click_button('Commit 1 file') + + expect(page).to have_content('Your changes have been committed') + expect(page).to have_selector('td', text: 'commit message') + end +end diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb index d70cf1527e7..a7928857b7d 100644 --- a/spec/features/security/project/internal_access_spec.rb +++ b/spec/features/security/project/internal_access_spec.rb @@ -181,6 +181,21 @@ describe "Internal Project Access" do it { is_expected.to be_denied_for(:visitor) } end + describe "GET /:project_path/issues/:id/edit" do + let(:issue) { create(:issue, project: project) } + subject { edit_project_issue_path(project, issue) } + + it { is_expected.to be_allowed_for(:admin) } + it { is_expected.to be_allowed_for(:owner).of(project) } + it { is_expected.to be_allowed_for(:master).of(project) } + it { is_expected.to be_allowed_for(:developer).of(project) } + it { is_expected.to be_allowed_for(:reporter).of(project) } + it { is_expected.to be_denied_for(:guest).of(project) } + it { is_expected.to be_denied_for(:user) } + it { is_expected.to be_denied_for(:external) } + it { is_expected.to be_denied_for(:visitor) } + end + describe "GET /:project_path/snippets" do subject { project_snippets_path(project) } diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb index ea130606545..a4396b20afd 100644 --- a/spec/features/security/project/private_access_spec.rb +++ b/spec/features/security/project/private_access_spec.rb @@ -181,6 +181,21 @@ describe "Private Project Access" do it { is_expected.to be_denied_for(:visitor) } end + describe "GET /:project_path/issues/:id/edit" do + let(:issue) { create(:issue, project: project) } + subject { edit_project_issue_path(project, issue) } + + it { is_expected.to be_allowed_for(:admin) } + it { is_expected.to be_allowed_for(:owner).of(project) } + it { is_expected.to be_allowed_for(:master).of(project) } + it { is_expected.to be_allowed_for(:developer).of(project) } + it { is_expected.to be_allowed_for(:reporter).of(project) } + it { is_expected.to be_denied_for(:guest).of(project) } + it { is_expected.to be_denied_for(:user) } + it { is_expected.to be_denied_for(:external) } + it { is_expected.to be_denied_for(:visitor) } + end + describe "GET /:project_path/snippets" do subject { project_snippets_path(project) } diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index d15f5af66c9..fccdeb0e5b7 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -394,6 +394,21 @@ describe "Public Project Access" do it { is_expected.to be_allowed_for(:visitor) } end + describe "GET /:project_path/issues/:id/edit" do + let(:issue) { create(:issue, project: project) } + subject { edit_project_issue_path(project, issue) } + + it { is_expected.to be_allowed_for(:admin) } + it { is_expected.to be_allowed_for(:owner).of(project) } + it { is_expected.to be_allowed_for(:master).of(project) } + it { is_expected.to be_allowed_for(:developer).of(project) } + it { is_expected.to be_allowed_for(:reporter).of(project) } + it { is_expected.to be_denied_for(:guest).of(project) } + it { is_expected.to be_denied_for(:user) } + it { is_expected.to be_denied_for(:external) } + it { is_expected.to be_denied_for(:visitor) } + end + describe "GET /:project_path/snippets" do subject { project_snippets_path(project) } diff --git a/spec/finders/branches_finder_spec.rb b/spec/finders/branches_finder_spec.rb index 91f34973ba5..9e3f2c69606 100644 --- a/spec/finders/branches_finder_spec.rb +++ b/spec/finders/branches_finder_spec.rb @@ -46,6 +46,15 @@ describe BranchesFinder do expect(result.count).to eq(1) end + it 'filters branches by name ignoring letter case' do + branches_finder = described_class.new(repository, { search: 'FiX' }) + + result = branches_finder.execute + + expect(result.first.name).to eq('fix') + expect(result.count).to eq(1) + end + it 'does not find any branch with that name' do branches_finder = described_class.new(repository, { search: 'random' }) diff --git a/spec/fixtures/api/schemas/public_api/v4/pages_domains.json b/spec/fixtures/api/schemas/public_api/v4/pages_domains.json new file mode 100644 index 00000000000..0de1d0f1228 --- /dev/null +++ b/spec/fixtures/api/schemas/public_api/v4/pages_domains.json @@ -0,0 +1,23 @@ +{ + "type": "array", + "items": { + "type": "object", + "properties": { + "domain": { "type": "string" }, + "url": { "type": "uri" }, + "certificate": { + "type": "object", + "properties": { + "subject": { "type": "string" }, + "expired": { "type": "boolean" }, + "certificate": { "type": "string" }, + "certificate_text": { "type": "string" } + }, + "required": ["subject", "expired"], + "additionalProperties": false + } + }, + "required": ["domain", "url"], + "additionalProperties": false + } +} diff --git a/spec/fixtures/ssh_host_example_key.pub b/spec/fixtures/ssh_host_example_key.pub new file mode 100644 index 00000000000..6bac42b3ad0 --- /dev/null +++ b/spec/fixtures/ssh_host_example_key.pub @@ -0,0 +1 @@ +random content diff --git a/spec/helpers/instance_configuration_helper_spec.rb b/spec/helpers/instance_configuration_helper_spec.rb new file mode 100644 index 00000000000..5d716b9191d --- /dev/null +++ b/spec/helpers/instance_configuration_helper_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +describe InstanceConfigurationHelper do + describe '#instance_configuration_cell_html' do + describe 'if not block is passed' do + it 'returns the parameter if present' do + expect(helper.instance_configuration_cell_html('gitlab')).to eq('gitlab') + end + + it 'returns "-" if the parameter is blank' do + expect(helper.instance_configuration_cell_html(nil)).to eq('-') + expect(helper.instance_configuration_cell_html('')).to eq('-') + end + end + + describe 'if a block is passed' do + let(:upcase_block) { ->(value) { value.upcase } } + + it 'returns the result of the block' do + expect(helper.instance_configuration_cell_html('gitlab', &upcase_block)).to eq('GITLAB') + expect(helper.instance_configuration_cell_html('gitlab') { |v| v.upcase }).to eq('GITLAB') + end + + it 'returns "-" if the parameter is blank' do + expect(helper.instance_configuration_cell_html(nil, &upcase_block)).to eq('-') + expect(helper.instance_configuration_cell_html(nil) { |v| v.upcase }).to eq('-') + expect(helper.instance_configuration_cell_html('', &upcase_block)).to eq('-') + end + end + + it 'boolean are valid values to display' do + expect(helper.instance_configuration_cell_html(true)).to eq(true) + expect(helper.instance_configuration_cell_html(false)).to eq(false) + end + end + + describe '#instance_configuration_human_size_cell' do + it 'returns "-" if the parameter is blank' do + expect(helper.instance_configuration_human_size_cell(nil)).to eq('-') + expect(helper.instance_configuration_human_size_cell('')).to eq('-') + end + + it 'accepts the value in bytes' do + expect(helper.instance_configuration_human_size_cell(1024)).to eq('1 KB') + end + + it 'returns the value in human size readable format' do + expect(helper.instance_configuration_human_size_cell(1048576)).to eq('1 MB') + end + end +end diff --git a/spec/javascripts/helpers/vue_mount_component_helper.js b/spec/javascripts/helpers/vue_mount_component_helper.js index d7a2e86771c..b71136c4114 100644 --- a/spec/javascripts/helpers/vue_mount_component_helper.js +++ b/spec/javascripts/helpers/vue_mount_component_helper.js @@ -1,4 +1,3 @@ -export default (Component, props = {}) => new Component({ +export default (Component, props = {}, el = null) => new Component({ propsData: props, -}).$mount(); - +}).$mount(el); diff --git a/spec/javascripts/merge_request_tabs_spec.js b/spec/javascripts/merge_request_tabs_spec.js index 18916c5aa97..e441d1153ed 100644 --- a/spec/javascripts/merge_request_tabs_spec.js +++ b/spec/javascripts/merge_request_tabs_spec.js @@ -5,8 +5,7 @@ import '~/merge_request_tabs'; import '~/commit/pipelines/pipelines_bundle'; import '~/breakpoints'; import '~/lib/utils/common_utils'; -import '~/diff'; -import '~/files_comment_button'; +import Diff from '~/diff'; import '~/notes'; import 'vendor/jquery.scrollTo'; @@ -225,7 +224,7 @@ import 'vendor/jquery.scrollTo'; describe('with "Side-by-side"/parallel diff view', () => { beforeEach(function () { this.class.diffViewType = () => 'parallel'; - gl.Diff.prototype.diffViewType = () => 'parallel'; + Diff.prototype.diffViewType = () => 'parallel'; }); it('maintains `container-limited` for pipelines tab', function (done) { diff --git a/spec/javascripts/notes/components/issue_placeholder_system_note_spec.js b/spec/javascripts/notes/components/issue_placeholder_system_note_spec.js deleted file mode 100644 index d508a49f710..00000000000 --- a/spec/javascripts/notes/components/issue_placeholder_system_note_spec.js +++ /dev/null @@ -1,24 +0,0 @@ -import Vue from 'vue'; -import placeholderSystemNote from '~/notes/components/issue_placeholder_system_note.vue'; - -describe('issue placeholder system note component', () => { - let mountComponent; - beforeEach(() => { - const PlaceholderSystemNote = Vue.extend(placeholderSystemNote); - - mountComponent = props => new PlaceholderSystemNote({ - propsData: { - note: { - body: props, - }, - }, - }).$mount(); - }); - - it('should render system note placeholder with plain text', () => { - const vm = mountComponent('This is a placeholder'); - - expect(vm.$el.tagName).toEqual('LI'); - expect(vm.$el.querySelector('.timeline-content em').textContent.trim()).toEqual('This is a placeholder'); - }); -}); diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js index 66c52611614..4546b88e44d 100644 --- a/spec/javascripts/notes_spec.js +++ b/spec/javascripts/notes_spec.js @@ -103,6 +103,16 @@ import '~/notes'; $('.js-comment-button').click(); expect(this.autoSizeSpy).toHaveBeenTriggered(); }); + + it('should not place escaped text in the comment box in case of error', function() { + const deferred = $.Deferred(); + spyOn($, 'ajax').and.returnValue(deferred.promise()); + $(textarea).text('A comment with `markup`.'); + + deferred.reject(); + $('.js-comment-button').click(); + expect($(textarea).val()).toEqual('A comment with `markup`.'); + }); }); describe('updateNote', () => { diff --git a/spec/javascripts/pipelines/pipelines_table_row_spec.js b/spec/javascripts/pipelines/pipelines_table_row_spec.js index d7456a48bc1..a9126d2f4e9 100644 --- a/spec/javascripts/pipelines/pipelines_table_row_spec.js +++ b/spec/javascripts/pipelines/pipelines_table_row_spec.js @@ -10,6 +10,7 @@ describe('Pipelines Table Row', () => { propsData: { pipeline, autoDevopsHelpPath: 'foo', + viewType: 'root', }, }).$mount(); }; diff --git a/spec/javascripts/pipelines/pipelines_table_spec.js b/spec/javascripts/pipelines/pipelines_table_spec.js index 4f5eb42eb35..ca2f9163313 100644 --- a/spec/javascripts/pipelines/pipelines_table_spec.js +++ b/spec/javascripts/pipelines/pipelines_table_spec.js @@ -23,6 +23,7 @@ describe('Pipelines Table', () => { propsData: { pipelines: [], autoDevopsHelpPath: 'foo', + viewType: 'root', }, }).$mount(); }); @@ -49,6 +50,7 @@ describe('Pipelines Table', () => { propsData: { pipelines: [], autoDevopsHelpPath: 'foo', + viewType: 'root', }, }).$mount(); expect(component.$el.querySelectorAll('.commit.gl-responsive-table-row').length).toEqual(0); @@ -61,6 +63,7 @@ describe('Pipelines Table', () => { propsData: { pipelines: [pipeline], autoDevopsHelpPath: 'foo', + viewType: 'root', }, }).$mount(); diff --git a/spec/javascripts/repo/components/new_branch_form_spec.js b/spec/javascripts/repo/components/new_branch_form_spec.js new file mode 100644 index 00000000000..c9c5ce096fc --- /dev/null +++ b/spec/javascripts/repo/components/new_branch_form_spec.js @@ -0,0 +1,122 @@ +import Vue from 'vue'; +import newBranchForm from '~/repo/components/new_branch_form.vue'; +import eventHub from '~/repo/event_hub'; +import RepoStore from '~/repo/stores/repo_store'; +import createComponent from '../../helpers/vue_mount_component_helper'; + +describe('Multi-file editor new branch form', () => { + let vm; + + beforeEach(() => { + const Component = Vue.extend(newBranchForm); + + RepoStore.currentBranch = 'master'; + + vm = createComponent(Component, { + currentBranch: RepoStore.currentBranch, + }); + }); + + afterEach(() => { + vm.$destroy(); + + RepoStore.currentBranch = ''; + }); + + describe('template', () => { + it('renders submit as disabled', () => { + expect(vm.$el.querySelector('.btn').getAttribute('disabled')).toBe('disabled'); + }); + + it('enables the submit button when branch is not empty', (done) => { + vm.branchName = 'testing'; + + Vue.nextTick(() => { + expect(vm.$el.querySelector('.btn').getAttribute('disabled')).toBeNull(); + + done(); + }); + }); + + it('displays current branch creating from', (done) => { + Vue.nextTick(() => { + expect(vm.$el.querySelector('p').textContent.replace(/\s+/g, ' ').trim()).toBe('Create from: master'); + + done(); + }); + }); + }); + + describe('submitNewBranch', () => { + it('sets to loading', () => { + vm.submitNewBranch(); + + expect(vm.loading).toBeTruthy(); + }); + + it('hides current flash element', (done) => { + vm.$refs.flashContainer.innerHTML = '
'; + + vm.submitNewBranch(); + + Vue.nextTick(() => { + expect(vm.$el.querySelector('.flash-alert')).toBeNull(); + + done(); + }); + }); + + it('emits an event with branchName', () => { + spyOn(eventHub, '$emit'); + + vm.branchName = 'testing'; + + vm.submitNewBranch(); + + expect(eventHub.$emit).toHaveBeenCalledWith('createNewBranch', 'testing'); + }); + }); + + describe('showErrorMessage', () => { + it('sets loading to false', () => { + vm.loading = true; + + vm.showErrorMessage(); + + expect(vm.loading).toBeFalsy(); + }); + + it('creates flash element', () => { + vm.showErrorMessage('error message'); + + expect(vm.$el.querySelector('.flash-alert')).not.toBeNull(); + expect(vm.$el.querySelector('.flash-alert').textContent.trim()).toBe('error message'); + }); + }); + + describe('createdNewBranch', () => { + it('set loading to false', () => { + vm.loading = true; + + vm.createdNewBranch(); + + expect(vm.loading).toBeFalsy(); + }); + + it('resets branch name', () => { + vm.branchName = 'testing'; + + vm.createdNewBranch(); + + expect(vm.branchName).toBe(''); + }); + + it('sets the dropdown toggle text', () => { + vm.dropdownText = document.createElement('span'); + + vm.createdNewBranch('branch name'); + + expect(vm.dropdownText.textContent).toBe('branch name'); + }); + }); +}); diff --git a/spec/javascripts/repo/components/new_dropdown/index_spec.js b/spec/javascripts/repo/components/new_dropdown/index_spec.js new file mode 100644 index 00000000000..ddbfdab582d --- /dev/null +++ b/spec/javascripts/repo/components/new_dropdown/index_spec.js @@ -0,0 +1,191 @@ +import Vue from 'vue'; +import newDropdown from '~/repo/components/new_dropdown/index.vue'; +import RepoStore from '~/repo/stores/repo_store'; +import RepoHelper from '~/repo/helpers/repo_helper'; +import eventHub from '~/repo/event_hub'; +import createComponent from '../../../helpers/vue_mount_component_helper'; + +describe('new dropdown component', () => { + let vm; + + beforeEach(() => { + const component = Vue.extend(newDropdown); + + vm = createComponent(component); + }); + + afterEach(() => { + vm.$destroy(); + + RepoStore.files = []; + RepoStore.openedFiles = []; + RepoStore.setViewToPreview(); + }); + + it('renders new file and new directory links', () => { + expect(vm.$el.querySelectorAll('a')[0].textContent.trim()).toBe('New file'); + expect(vm.$el.querySelectorAll('a')[1].textContent.trim()).toBe('New directory'); + }); + + describe('createNewItem', () => { + it('sets modalType to blob when new file is clicked', () => { + vm.$el.querySelectorAll('a')[0].click(); + + expect(vm.modalType).toBe('blob'); + }); + + it('sets modalType to tree when new directory is clicked', () => { + vm.$el.querySelectorAll('a')[1].click(); + + expect(vm.modalType).toBe('tree'); + }); + + it('opens modal when link is clicked', (done) => { + vm.$el.querySelectorAll('a')[0].click(); + + Vue.nextTick(() => { + expect(vm.$el.querySelector('.modal')).not.toBeNull(); + + done(); + }); + }); + }); + + describe('toggleModalOpen', () => { + it('closes modal after toggling', (done) => { + vm.toggleModalOpen(); + + Vue.nextTick() + .then(() => { + expect(vm.$el.querySelector('.modal')).not.toBeNull(); + }) + .then(vm.toggleModalOpen) + .then(() => { + expect(vm.$el.querySelector('.modal')).toBeNull(); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('createEntryInStore', () => { + ['tree', 'blob'].forEach((type) => { + describe(type, () => { + it('closes modal after creating file', () => { + vm.openModal = true; + + eventHub.$emit('createNewEntry', 'testing', type); + + expect(vm.openModal).toBeFalsy(); + }); + + it('sets editMode to true', () => { + eventHub.$emit('createNewEntry', 'testing', type); + + expect(RepoStore.editMode).toBeTruthy(); + }); + + it('toggles blob view', () => { + eventHub.$emit('createNewEntry', 'testing', type); + + expect(RepoStore.isPreviewView()).toBeFalsy(); + }); + + it('adds file into activeFiles', () => { + eventHub.$emit('createNewEntry', 'testing', type); + + expect(RepoStore.openedFiles.length).toBe(1); + }); + + it(`creates ${type} in the current stores path`, () => { + RepoStore.path = 'testing'; + + eventHub.$emit('createNewEntry', 'testing/app', type); + + expect(RepoStore.files[0].path).toBe('testing/app'); + expect(RepoStore.files[0].name).toBe('app'); + + if (type === 'tree') { + expect(RepoStore.files[0].files.length).toBe(1); + } + + RepoStore.path = ''; + }); + }); + }); + + describe('file', () => { + it('creates new file', () => { + eventHub.$emit('createNewEntry', 'testing', 'blob'); + + expect(RepoStore.files.length).toBe(1); + expect(RepoStore.files[0].name).toBe('testing'); + expect(RepoStore.files[0].type).toBe('blob'); + expect(RepoStore.files[0].tempFile).toBeTruthy(); + }); + + it('does not create temp file when file already exists', () => { + RepoStore.files.push(RepoHelper.serializeRepoEntity('blob', { + name: 'testing', + })); + + eventHub.$emit('createNewEntry', 'testing', 'blob'); + + expect(RepoStore.files.length).toBe(1); + expect(RepoStore.files[0].name).toBe('testing'); + expect(RepoStore.files[0].type).toBe('blob'); + expect(RepoStore.files[0].tempFile).toBeUndefined(); + }); + }); + + describe('tree', () => { + it('creates new tree', () => { + eventHub.$emit('createNewEntry', 'testing', 'tree'); + + expect(RepoStore.files.length).toBe(1); + expect(RepoStore.files[0].name).toBe('testing'); + expect(RepoStore.files[0].type).toBe('tree'); + expect(RepoStore.files[0].tempFile).toBeTruthy(); + expect(RepoStore.files[0].files.length).toBe(1); + expect(RepoStore.files[0].files[0].name).toBe('.gitkeep'); + }); + + it('creates multiple trees when entryName has slashes', () => { + eventHub.$emit('createNewEntry', 'app/test', 'tree'); + + expect(RepoStore.files.length).toBe(1); + expect(RepoStore.files[0].name).toBe('app'); + expect(RepoStore.files[0].files[0].name).toBe('test'); + expect(RepoStore.files[0].files[0].files[0].name).toBe('.gitkeep'); + }); + + it('creates tree in existing tree', () => { + RepoStore.files.push(RepoHelper.serializeRepoEntity('tree', { + name: 'app', + })); + + eventHub.$emit('createNewEntry', 'app/test', 'tree'); + + expect(RepoStore.files.length).toBe(1); + expect(RepoStore.files[0].name).toBe('app'); + expect(RepoStore.files[0].tempFile).toBeUndefined(); + expect(RepoStore.files[0].files[0].tempFile).toBeTruthy(); + expect(RepoStore.files[0].files[0].name).toBe('test'); + expect(RepoStore.files[0].files[0].files[0].name).toBe('.gitkeep'); + }); + + it('does not create new tree when already exists', () => { + RepoStore.files.push(RepoHelper.serializeRepoEntity('tree', { + name: 'app', + })); + + eventHub.$emit('createNewEntry', 'app', 'tree'); + + expect(RepoStore.files.length).toBe(1); + expect(RepoStore.files[0].name).toBe('app'); + expect(RepoStore.files[0].tempFile).toBeUndefined(); + expect(RepoStore.files[0].files.length).toBe(0); + }); + }); + }); +}); diff --git a/spec/javascripts/repo/components/new_dropdown/modal_spec.js b/spec/javascripts/repo/components/new_dropdown/modal_spec.js new file mode 100644 index 00000000000..4c5cdc47c6e --- /dev/null +++ b/spec/javascripts/repo/components/new_dropdown/modal_spec.js @@ -0,0 +1,76 @@ +import Vue from 'vue'; +import RepoStore from '~/repo/stores/repo_store'; +import modal from '~/repo/components/new_dropdown/modal.vue'; +import eventHub from '~/repo/event_hub'; +import createComponent from '../../../helpers/vue_mount_component_helper'; + +describe('new file modal component', () => { + const Component = Vue.extend(modal); + let vm; + + afterEach(() => { + vm.$destroy(); + + RepoStore.files = []; + RepoStore.openedFiles = []; + RepoStore.setViewToPreview(); + }); + + ['tree', 'blob'].forEach((type) => { + describe(type, () => { + beforeEach(() => { + vm = createComponent(Component, { + type, + currentPath: RepoStore.path, + }); + }); + + it(`sets modal title as ${type}`, () => { + const title = type === 'tree' ? 'directory' : 'file'; + + expect(vm.$el.querySelector('.modal-title').textContent.trim()).toBe(`Create new ${title}`); + }); + + it(`sets button label as ${type}`, () => { + const title = type === 'tree' ? 'directory' : 'file'; + + expect(vm.$el.querySelector('.btn-success').textContent.trim()).toBe(`Create ${title}`); + }); + + it(`sets form label as ${type}`, () => { + const title = type === 'tree' ? 'Directory' : 'File'; + + expect(vm.$el.querySelector('.label-light').textContent.trim()).toBe(`${title} name`); + }); + }); + }); + + it('focuses field on mount', () => { + document.body.innerHTML += '
'; + + vm = createComponent(Component, { + type: 'tree', + currentPath: RepoStore.path, + }, '.js-test'); + + expect(document.activeElement).toBe(vm.$refs.fieldName); + + vm.$el.remove(); + }); + + describe('createEntryInStore', () => { + it('emits createNewEntry event', () => { + spyOn(eventHub, '$emit'); + + vm = createComponent(Component, { + type: 'tree', + currentPath: RepoStore.path, + }); + vm.entryName = 'testing'; + + vm.createEntryInStore(); + + expect(eventHub.$emit).toHaveBeenCalledWith('createNewEntry', 'testing', 'tree'); + }); + }); +}); diff --git a/spec/javascripts/repo/components/repo_file_buttons_spec.js b/spec/javascripts/repo/components/repo_file_buttons_spec.js index 701c260224f..111c83ee50d 100644 --- a/spec/javascripts/repo/components/repo_file_buttons_spec.js +++ b/spec/javascripts/repo/components/repo_file_buttons_spec.js @@ -3,6 +3,15 @@ import repoFileButtons from '~/repo/components/repo_file_buttons.vue'; import RepoStore from '~/repo/stores/repo_store'; describe('RepoFileButtons', () => { + const activeFile = { + extension: 'md', + url: 'url', + raw_path: 'raw_path', + blame_path: 'blame_path', + commits_path: 'commits_path', + permalink: 'permalink', + }; + function createComponent() { const RepoFileButtons = Vue.extend(repoFileButtons); @@ -14,14 +23,6 @@ describe('RepoFileButtons', () => { }); it('renders Raw, Blame, History, Permalink and Preview toggle', () => { - const activeFile = { - extension: 'md', - url: 'url', - raw_path: 'raw_path', - blame_path: 'blame_path', - commits_path: 'commits_path', - permalink: 'permalink', - }; const activeFileLabel = 'activeFileLabel'; RepoStore.openedFiles = new Array(1); RepoStore.activeFile = activeFile; @@ -34,7 +35,6 @@ describe('RepoFileButtons', () => { const blame = vm.$el.querySelector('.blame'); const history = vm.$el.querySelector('.history'); - expect(vm.$el.id).toEqual('repo-file-buttons'); expect(raw.href).toMatch(`/${activeFile.raw_path}`); expect(raw.textContent.trim()).toEqual('Raw'); expect(blame.href).toMatch(`/${activeFile.blame_path}`); @@ -46,10 +46,6 @@ describe('RepoFileButtons', () => { }); it('triggers rawPreviewToggle on preview click', () => { - const activeFile = { - extension: 'md', - url: 'url', - }; RepoStore.openedFiles = new Array(1); RepoStore.activeFile = activeFile; RepoStore.editMode = true; @@ -65,10 +61,7 @@ describe('RepoFileButtons', () => { }); it('does not render preview toggle if not canPreview', () => { - const activeFile = { - extension: 'abcd', - url: 'url', - }; + activeFile.extension = 'js'; RepoStore.openedFiles = new Array(1); RepoStore.activeFile = activeFile; diff --git a/spec/javascripts/repo/components/repo_file_spec.js b/spec/javascripts/repo/components/repo_file_spec.js index 107f6797f8a..8403df9be64 100644 --- a/spec/javascripts/repo/components/repo_file_spec.js +++ b/spec/javascripts/repo/components/repo_file_spec.js @@ -7,6 +7,7 @@ import { file } from '../mock_data'; describe('RepoFile', () => { const updated = 'updated'; const otherFile = { + id: 'test', html: '

html

', pageTitle: 'otherpageTitle', }; diff --git a/spec/javascripts/repo/components/repo_spec.js b/spec/javascripts/repo/components/repo_spec.js new file mode 100644 index 00000000000..3558a155728 --- /dev/null +++ b/spec/javascripts/repo/components/repo_spec.js @@ -0,0 +1,96 @@ +import Vue from 'vue'; +import repo from '~/repo/components/repo.vue'; +import RepoStore from '~/repo/stores/repo_store'; +import Service from '~/repo/services/repo_service'; +import eventHub from '~/repo/event_hub'; +import createComponent from '../../helpers/vue_mount_component_helper'; + +describe('repo component', () => { + let vm; + + beforeEach(() => { + const Component = Vue.extend(repo); + + RepoStore.currentBranch = 'master'; + + vm = createComponent(Component); + }); + + afterEach(() => { + vm.$destroy(); + + RepoStore.currentBranch = ''; + }); + + describe('createNewBranch', () => { + beforeEach(() => { + spyOn(history, 'pushState'); + }); + + describe('success', () => { + beforeEach(() => { + spyOn(Service, 'createBranch').and.returnValue(Promise.resolve({ + data: { + name: 'test', + }, + })); + }); + + it('calls createBranch with branchName', () => { + eventHub.$emit('createNewBranch', 'test'); + + expect(Service.createBranch).toHaveBeenCalledWith({ + branch: 'test', + ref: RepoStore.currentBranch, + }); + }); + + it('pushes new history state', (done) => { + RepoStore.currentBranch = 'master'; + + spyOn(vm, 'getCurrentLocation').and.returnValue('http://test.com/master'); + + eventHub.$emit('createNewBranch', 'test'); + + setTimeout(() => { + expect(history.pushState).toHaveBeenCalledWith(jasmine.anything(), '', 'http://test.com/test'); + done(); + }); + }); + + it('updates stores currentBranch', (done) => { + eventHub.$emit('createNewBranch', 'test'); + + setTimeout(() => { + expect(RepoStore.currentBranch).toBe('test'); + + done(); + }); + }); + }); + + describe('failure', () => { + beforeEach(() => { + spyOn(Service, 'createBranch').and.returnValue(Promise.reject({ + response: { + data: { + message: 'test', + }, + }, + })); + }); + + it('emits createNewBranchError event', (done) => { + spyOn(eventHub, '$emit').and.callThrough(); + + eventHub.$emit('createNewBranch', 'test'); + + setTimeout(() => { + expect(eventHub.$emit).toHaveBeenCalledWith('createNewBranchError', 'test'); + + done(); + }); + }); + }); + }); +}); diff --git a/spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js b/spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js index d7019ea408b..df3d29ee1f9 100644 --- a/spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js +++ b/spec/javascripts/vue_mr_widget/components/states/mr_widget_ready_to_merge_spec.js @@ -43,6 +43,10 @@ describe('MRWidgetReadyToMerge', () => { vm = createComponent(); }); + afterEach(() => { + vm.$destroy(); + }); + describe('props', () => { it('should have props', () => { const { mr, service } = readyToMergeComponent.props; @@ -495,6 +499,48 @@ describe('MRWidgetReadyToMerge', () => { }); }); + describe('Merge controls', () => { + describe('when allowed to merge', () => { + beforeEach(() => { + vm = createComponent({ + mr: { isMergeAllowed: true }, + }); + }); + + it('shows remove source branch checkbox', () => { + expect(vm.$el.querySelector('.js-remove-source-branch-checkbox')).toBeDefined(); + }); + + it('shows modify commit message button', () => { + expect(vm.$el.querySelector('.js-modify-commit-message-button')).toBeDefined(); + }); + + it('does not show message about needing to resolve items', () => { + expect(vm.$el.querySelector('.js-resolve-mr-widget-items-message')).toBeNull(); + }); + }); + + describe('when not allowed to merge', () => { + beforeEach(() => { + vm = createComponent({ + mr: { isMergeAllowed: false }, + }); + }); + + it('does not show remove source branch checkbox', () => { + expect(vm.$el.querySelector('.js-remove-source-branch-checkbox')).toBeNull(); + }); + + it('does not show modify commit message button', () => { + expect(vm.$el.querySelector('.js-modify-commit-message-button')).toBeNull(); + }); + + it('shows message to resolve all items before being allowed to merge', () => { + expect(vm.$el.querySelector('.js-resolve-mr-widget-items-message')).toBeDefined(); + }); + }); + }); + describe('Commit message area', () => { it('when using merge commits, should show "Modify commit message" button', () => { const customVm = createComponent({ diff --git a/spec/javascripts/vue_shared/components/ci_badge_link_spec.js b/spec/javascripts/vue_shared/components/ci_badge_link_spec.js index daed4da3e15..ba303738f71 100644 --- a/spec/javascripts/vue_shared/components/ci_badge_link_spec.js +++ b/spec/javascripts/vue_shared/components/ci_badge_link_spec.js @@ -1,8 +1,10 @@ import Vue from 'vue'; import ciBadge from '~/vue_shared/components/ci_badge_link.vue'; +import mountComponent from '../../helpers/vue_mount_component_helper'; describe('CI Badge Link Component', () => { let CIBadge; + let vm; const statuses = { canceled: { @@ -70,15 +72,17 @@ describe('CI Badge Link Component', () => { }, }; - it('should render each status badge', () => { + beforeEach(() => { CIBadge = Vue.extend(ciBadge); - Object.keys(statuses).map((status) => { - const vm = new CIBadge({ - propsData: { - status: statuses[status], - }, - }).$mount(); + }); + afterEach(() => { + vm.$destroy(); + }); + + it('should render each status badge', () => { + Object.keys(statuses).map((status) => { + vm = mountComponent(CIBadge, { status: statuses[status] }); expect(vm.$el.getAttribute('href')).toEqual(statuses[status].details_path); expect(vm.$el.textContent.trim()).toEqual(statuses[status].text); expect(vm.$el.getAttribute('class')).toEqual(`ci-status ci-${statuses[status].group}`); @@ -86,4 +90,9 @@ describe('CI Badge Link Component', () => { return vm; }); }); + + it('should not render label', () => { + vm = mountComponent(CIBadge, { status: statuses.canceled, showText: false }); + expect(vm.$el.textContent.trim()).toEqual(''); + }); }); diff --git a/spec/javascripts/vue_shared/components/loading_button_spec.js b/spec/javascripts/vue_shared/components/loading_button_spec.js new file mode 100644 index 00000000000..97c8a08fcdd --- /dev/null +++ b/spec/javascripts/vue_shared/components/loading_button_spec.js @@ -0,0 +1,93 @@ +import Vue from 'vue'; +import loadingButton from '~/vue_shared/components/loading_button.vue'; +import mountComponent from '../../helpers/vue_mount_component_helper'; + +const LABEL = 'Hello'; + +describe('LoadingButton', function () { + let vm; + let LoadingButton; + + beforeEach(() => { + LoadingButton = Vue.extend(loadingButton); + }); + + afterEach(() => { + vm.$destroy(); + }); + + describe('loading spinner', () => { + it('shown when loading', () => { + vm = mountComponent(LoadingButton, { + loading: true, + }); + + expect(vm.$el.querySelector('.js-loading-button-icon')).toBeDefined(); + }); + }); + + describe('disabled state', () => { + it('disabled when loading', () => { + vm = mountComponent(LoadingButton, { + loading: true, + }); + + expect(vm.$el.disabled).toEqual(true); + }); + + it('not disabled when normal', () => { + vm = mountComponent(LoadingButton, { + loading: false, + }); + + expect(vm.$el.disabled).toEqual(false); + }); + }); + + describe('label', () => { + it('shown when normal', () => { + vm = mountComponent(LoadingButton, { + loading: false, + label: LABEL, + }); + const label = vm.$el.querySelector('.js-loading-button-label'); + + expect(label.textContent.trim()).toEqual(LABEL); + }); + + it('shown when loading', () => { + vm = mountComponent(LoadingButton, { + loading: true, + label: LABEL, + }); + const label = vm.$el.querySelector('.js-loading-button-label'); + + expect(label.textContent.trim()).toEqual(LABEL); + }); + }); + + describe('click callback prop', () => { + it('calls given callback when normal', () => { + vm = mountComponent(LoadingButton, { + loading: false, + }); + spyOn(vm, '$emit'); + + vm.$el.click(); + + expect(vm.$emit).toHaveBeenCalledWith('click', jasmine.any(Object)); + }); + + it('does not call given callback when disabled because of loading', () => { + vm = mountComponent(LoadingButton, { + loading: true, + indeterminate: true, + }); + spyOn(vm, '$emit'); + + vm.$el.click(); + + expect(vm.$emit).not.toHaveBeenCalled(); + }); + }); +}); diff --git a/spec/javascripts/notes/components/issue_placeholder_note_spec.js b/spec/javascripts/vue_shared/components/notes/placeholder_note_spec.js similarity index 89% rename from spec/javascripts/notes/components/issue_placeholder_note_spec.js rename to spec/javascripts/vue_shared/components/notes/placeholder_note_spec.js index 6e5275087f3..ba8ab0b2cd7 100644 --- a/spec/javascripts/notes/components/issue_placeholder_note_spec.js +++ b/spec/javascripts/vue_shared/components/notes/placeholder_note_spec.js @@ -1,7 +1,7 @@ import Vue from 'vue'; -import issuePlaceholderNote from '~/notes/components/issue_placeholder_note.vue'; +import issuePlaceholderNote from '~/vue_shared/components/notes/placeholder_note.vue'; import store from '~/notes/stores'; -import { userDataMock } from '../mock_data'; +import { userDataMock } from '../../../notes/mock_data'; describe('issue placeholder system note component', () => { let vm; diff --git a/spec/javascripts/vue_shared/components/notes/placeholder_system_note_spec.js b/spec/javascripts/vue_shared/components/notes/placeholder_system_note_spec.js new file mode 100644 index 00000000000..7b8e6c330c2 --- /dev/null +++ b/spec/javascripts/vue_shared/components/notes/placeholder_system_note_spec.js @@ -0,0 +1,25 @@ +import Vue from 'vue'; +import placeholderSystemNote from '~/vue_shared/components/notes/placeholder_system_note.vue'; +import mountComponent from '../../../helpers/vue_mount_component_helper'; + +describe('placeholder system note component', () => { + let PlaceholderSystemNote; + let vm; + + beforeEach(() => { + PlaceholderSystemNote = Vue.extend(placeholderSystemNote); + }); + + afterEach(() => { + vm.$destroy(); + }); + + it('should render system note placeholder with plain text', () => { + vm = mountComponent(PlaceholderSystemNote, { + note: { body: 'This is a placeholder' }, + }); + + expect(vm.$el.tagName).toEqual('LI'); + expect(vm.$el.querySelector('.timeline-content em').textContent.trim()).toEqual('This is a placeholder'); + }); +}); diff --git a/spec/javascripts/notes/components/issue_system_note_spec.js b/spec/javascripts/vue_shared/components/notes/system_note_spec.js similarity index 91% rename from spec/javascripts/notes/components/issue_system_note_spec.js rename to spec/javascripts/vue_shared/components/notes/system_note_spec.js index c317ce32716..36aaf0a6c2e 100644 --- a/spec/javascripts/notes/components/issue_system_note_spec.js +++ b/spec/javascripts/vue_shared/components/notes/system_note_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import issueSystemNote from '~/notes/components/issue_system_note.vue'; +import issueSystemNote from '~/vue_shared/components/notes/system_note.vue'; import store from '~/notes/stores'; describe('issue system note', () => { @@ -33,6 +33,10 @@ describe('issue system note', () => { }).$mount(); }); + afterEach(() => { + vm.$destroy(); + }); + it('should render a list item with correct id', () => { expect(vm.$el.getAttribute('id')).toEqual(`note_${props.note.id}`); }); diff --git a/spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js b/spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js index 52e450e9ba5..8450ad9dbcb 100644 --- a/spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js +++ b/spec/javascripts/vue_shared/components/user_avatar/user_avatar_link_spec.js @@ -11,6 +11,7 @@ describe('User Avatar Link Component', function () { imgCssClasses: 'myextraavatarclass', tooltipText: 'tooltip text', tooltipPlacement: 'bottom', + username: 'username', }; const UserAvatarLinkComponent = Vue.extend(UserAvatarLink); @@ -47,4 +48,42 @@ describe('User Avatar Link Component', function () { expect(this.userAvatarLink[key]).toBeDefined(); }); }); + + describe('no username', function () { + beforeEach(function (done) { + this.userAvatarLink.username = ''; + + Vue.nextTick(done); + }); + + it('should only render image tag in link', function () { + const childElements = this.userAvatarLink.$el.childNodes; + expect(childElements[0].tagName).toBe('IMG'); + + // Vue will render the hidden component as + expect(childElements[1].tagName).toBeUndefined(); + }); + + it('should render avatar image tooltip', function () { + expect(this.userAvatarLink.$el.querySelector('img').dataset.originalTitle).toEqual(this.propsData.tooltipText); + }); + }); + + describe('username', function () { + it('should not render avatar image tooltip', function () { + expect(this.userAvatarLink.$el.querySelector('img').dataset.originalTitle).toEqual(''); + }); + + it('should render username prop in ', function () { + expect(this.userAvatarLink.$el.querySelector('span').innerText.trim()).toEqual(this.propsData.username); + }); + + it('should render text tooltip for ', function () { + expect(this.userAvatarLink.$el.querySelector('span').dataset.originalTitle).toEqual(this.propsData.tooltipText); + }); + + it('should render text tooltip placement for ', function () { + expect(this.userAvatarLink.$el.querySelector('span').getAttribute('tooltip-placement')).toEqual(this.propsData.tooltipPlacement); + }); + }); }); diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb index 97d612e6347..ca76d6f0881 100644 --- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb +++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb @@ -15,9 +15,13 @@ describe Banzai::Filter::GollumTagsFilter do context 'linking internal images' do it 'creates img tag if image exists' do - file = Gollum::File.new(project_wiki.wiki) - expect(file).to receive(:path).and_return('images/image.jpg') - expect(project_wiki).to receive(:find_file).with('images/image.jpg').and_return(file) + gollum_file_double = double('Gollum::File', + mime_type: 'image/jpeg', + name: 'images/image.jpg', + path: 'images/image.jpg', + raw_data: '') + wiki_file = Gitlab::Git::WikiFile.new(gollum_file_double) + expect(project_wiki).to receive(:find_file).with('images/image.jpg').and_return(wiki_file) tag = '[[images/image.jpg]]' doc = filter("See #{tag}", project_wiki: project_wiki) diff --git a/spec/lib/gitlab/app_logger_spec.rb b/spec/lib/gitlab/app_logger_spec.rb new file mode 100644 index 00000000000..c86d30ce6df --- /dev/null +++ b/spec/lib/gitlab/app_logger_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe Gitlab::AppLogger, :request_store do + subject { described_class } + + it 'builds a logger once' do + expect(::Logger).to receive(:new).and_call_original + + subject.info('hello world') + subject.error('hello again') + end +end diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index 318a7b7a332..708870060e7 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -7,6 +7,38 @@ describe Gitlab::Git::Branch, seed_helper: true do it { is_expected.to be_kind_of Array } + describe '.find' do + subject { described_class.find(repository, branch) } + + before do + allow(repository).to receive(:find_branch).with(branch) + .and_call_original + end + + context 'when finding branch via branch name' do + let(:branch) { 'master' } + + it 'returns a branch object' do + expect(subject).to be_a(described_class) + expect(subject.name).to eq(branch) + + expect(repository).to have_received(:find_branch).with(branch) + end + end + + context 'when the branch is already a branch' do + let(:commit) { repository.commit('master') } + let(:branch) { described_class.new(repository, 'master', commit.sha, commit) } + + it 'returns a branch object' do + expect(subject).to be_a(described_class) + expect(subject).to eq(branch) + + expect(repository).not_to have_received(:find_branch).with(branch) + end + end + end + describe '#size' do subject { super().size } it { is_expected.to eq(SeedRepo::Repo::BRANCHES.size) } diff --git a/spec/lib/gitlab/git/hooks_service_spec.rb b/spec/lib/gitlab/git/hooks_service_spec.rb index 51e4e3fdad1..3ed3feb4c74 100644 --- a/spec/lib/gitlab/git/hooks_service_spec.rb +++ b/spec/lib/gitlab/git/hooks_service_spec.rb @@ -1,24 +1,26 @@ require 'spec_helper' describe Gitlab::Git::HooksService, seed_helper: true do - let(:user) { Gitlab::Git::User.new('janedoe', 'Jane Doe', 'janedoe@example.com', 'user-456') } + let(:gl_id) { 'user-456' } + let(:gl_username) { 'janedoe' } + let(:user) { Gitlab::Git::User.new(gl_username, 'Jane Doe', 'janedoe@example.com', gl_id) } let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, 'project-123') } let(:service) { described_class.new } - - before do - @blankrev = Gitlab::Git::BLANK_SHA - @oldrev = SeedRepo::Commit::PARENT_ID - @newrev = SeedRepo::Commit::ID - @ref = 'refs/heads/feature' - end + let(:blankrev) { Gitlab::Git::BLANK_SHA } + let(:oldrev) { SeedRepo::Commit::PARENT_ID } + let(:newrev) { SeedRepo::Commit::ID } + let(:ref) { 'refs/heads/feature' } describe '#execute' do context 'when receive hooks were successful' do - it 'calls post-receive hook' do - hook = double(trigger: [true, nil]) - expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) + let(:hook) { double(:hook) } - service.execute(user, repository, @blankrev, @newrev, @ref) { } + it 'calls all three hooks' do + expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) + expect(hook).to receive(:trigger).with(gl_id, gl_username, blankrev, newrev, ref) + .exactly(3).times.and_return([true, nil]) + + service.execute(user, repository, blankrev, newrev, ref) { } end end @@ -28,7 +30,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do expect(service).not_to receive(:run_hook).with('post-receive') expect do - service.execute(user, repository, @blankrev, @newrev, @ref) + service.execute(user, repository, blankrev, newrev, ref) end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end end @@ -40,7 +42,7 @@ describe Gitlab::Git::HooksService, seed_helper: true do expect(service).not_to receive(:run_hook).with('post-receive') expect do - service.execute(user, repository, @blankrev, @newrev, @ref) + service.execute(user, repository, blankrev, newrev, ref) end.to raise_error(Gitlab::Git::HooksService::PreReceiveError) end end diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index b2d2f770e3d..b161d25b96c 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -1135,6 +1135,32 @@ describe Gitlab::Git::Repository, seed_helper: true do end end + describe '#merged_branch_names' do + context 'when branch names are passed' do + it 'only returns the names we are asking' do + names = repository.merged_branch_names(%w[merge-test]) + + expect(names).to contain_exactly('merge-test') + end + + it 'does not return unmerged branch names' do + names = repository.merged_branch_names(%w[feature]) + + expect(names).to be_empty + end + end + + context 'when no branch names are specified' do + it 'returns all merged branch names' do + names = repository.merged_branch_names + + expect(names).to include('merge-test') + expect(names).to include('fix-mode') + expect(names).not_to include('feature') + end + end + end + describe "#ls_files" do let(:master_file_paths) { repository.ls_files("master") } let(:not_existed_branch) { repository.ls_files("not_existed_branch") } @@ -1564,6 +1590,60 @@ describe Gitlab::Git::Repository, seed_helper: true do end end + describe '#ff_merge' do + let(:repository) do + Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '') + end + let(:branch_head) { '6d394385cf567f80a8fd85055db1ab4c5295806f' } + let(:source_sha) { 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660' } + let(:user) { build(:user) } + let(:target_branch) { 'test-ff-target-branch' } + + before do + repository.create_branch(target_branch, branch_head) + end + + after do + ensure_seeds + end + + subject { repository.ff_merge(user, source_sha, target_branch) } + + it 'performs a ff_merge' do + expect(subject.newrev).to eq(source_sha) + expect(subject.repo_created).to be(false) + expect(subject.branch_created).to be(false) + + expect(repository.commit(target_branch).id).to eq(source_sha) + end + + context 'with a non-existing target branch' do + subject { repository.ff_merge(user, source_sha, 'this-isnt-real') } + + it 'throws an ArgumentError' do + expect { subject }.to raise_error(ArgumentError) + end + end + + context 'with a non-existing source commit' do + let(:source_sha) { 'f001' } + + it 'throws an ArgumentError' do + expect { subject }.to raise_error(ArgumentError) + end + end + + context 'when the source sha is not a descendant of the branch head' do + let(:source_sha) { '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863' } + + it "doesn't perform the ff_merge" do + expect { subject }.to raise_error(Gitlab::Git::CommitError) + + expect(repository.commit(target_branch).id).to eq(branch_head) + end + end + end + def create_remote_branch(repository, remote_name, branch_name, source_branch_name) source_branch = repository.branches.find { |branch| branch.name == source_branch_name } rugged = repository.rugged diff --git a/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb b/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb index c8d532df059..72dabca793a 100644 --- a/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb +++ b/spec/lib/gitlab/git/storage/circuit_breaker_spec.rb @@ -79,7 +79,9 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state: stub_application_setting(circuitbreaker_failure_count_threshold: 0, circuitbreaker_failure_wait_time: 1, circuitbreaker_failure_reset_time: 2, - circuitbreaker_storage_timeout: 3) + circuitbreaker_storage_timeout: 3, + circuitbreaker_access_retries: 4, + circuitbreaker_backoff_threshold: 5) end describe '#failure_count_threshold' do @@ -105,14 +107,43 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state: expect(circuit_breaker.storage_timeout).to eq(3) end end + + describe '#access_retries' do + it 'reads the value from settings' do + expect(circuit_breaker.access_retries).to eq(4) + end + end + + describe '#backoff_threshold' do + it 'reads the value from settings' do + expect(circuit_breaker.backoff_threshold).to eq(5) + end + end end describe '#perform' do - it 'raises an exception with retry time when the circuit is open' do - allow(circuit_breaker).to receive(:circuit_broken?).and_return(true) + it 'raises the correct exception when the circuit is open' do + set_in_redis(:last_failure, 1.day.ago.to_f) + set_in_redis(:failure_count, 999) expect { |b| circuit_breaker.perform(&b) } - .to raise_error(Gitlab::Git::Storage::CircuitOpen) + .to raise_error do |exception| + expect(exception).to be_kind_of(Gitlab::Git::Storage::CircuitOpen) + expect(exception.retry_after).to eq(1800) + end + end + + it 'raises the correct exception when backing off' do + Timecop.freeze do + set_in_redis(:last_failure, 1.second.ago.to_f) + set_in_redis(:failure_count, 90) + + expect { |b| circuit_breaker.perform(&b) } + .to raise_error do |exception| + expect(exception).to be_kind_of(Gitlab::Git::Storage::Failing) + expect(exception.retry_after).to eq(30) + end + end end it 'yields the block' do @@ -122,6 +153,7 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state: it 'checks if the storage is available' do expect(circuit_breaker).to receive(:check_storage_accessible!) + .and_call_original circuit_breaker.perform { 'hello world' } end @@ -137,16 +169,82 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state: .to raise_error(Rugged::OSError) end - context 'with the feature disabled' do - it 'returns the block without checking accessibility' do - stub_feature_flags(git_storage_circuit_breaker: false) + it 'tracks that the storage was accessible' do + set_in_redis(:failure_count, 10) + set_in_redis(:last_failure, Time.now.to_f) - expect(circuit_breaker).not_to receive(:circuit_broken?) + circuit_breaker.perform { '' } + + expect(value_from_redis(:failure_count).to_i).to eq(0) + expect(value_from_redis(:last_failure)).to be_empty + expect(circuit_breaker.failure_count).to eq(0) + expect(circuit_breaker.last_failure).to be_nil + end + + it 'only performs the accessibility check once' do + expect(Gitlab::Git::Storage::ForkedStorageCheck) + .to receive(:storage_available?).once.and_call_original + + 2.times { circuit_breaker.perform { '' } } + end + + it 'calls the check with the correct arguments' do + stub_application_setting(circuitbreaker_storage_timeout: 30, + circuitbreaker_access_retries: 3) + + expect(Gitlab::Git::Storage::ForkedStorageCheck) + .to receive(:storage_available?).with(TestEnv.repos_path, 30, 3) + .and_call_original + + circuit_breaker.perform { '' } + end + + context 'with the feature disabled' do + before do + stub_feature_flags(git_storage_circuit_breaker: false) + end + + it 'returns the block without checking accessibility' do + expect(circuit_breaker).not_to receive(:check_storage_accessible!) result = circuit_breaker.perform { 'hello' } expect(result).to eq('hello') end + + it 'allows enabling the feature using an ENV var' do + stub_env('GIT_STORAGE_CIRCUIT_BREAKER', 'true') + expect(circuit_breaker).to receive(:check_storage_accessible!) + + result = circuit_breaker.perform { 'hello' } + + expect(result).to eq('hello') + end + end + + context 'the storage is not available' do + let(:storage_name) { 'broken' } + + it 'raises the correct exception' do + expect(circuit_breaker).to receive(:track_storage_inaccessible) + + expect { circuit_breaker.perform { '' } } + .to raise_error do |exception| + expect(exception).to be_kind_of(Gitlab::Git::Storage::Inaccessible) + expect(exception.retry_after).to eq(30) + end + end + + it 'tracks that the storage was inaccessible' do + Timecop.freeze do + expect { circuit_breaker.perform { '' } }.to raise_error(Gitlab::Git::Storage::Inaccessible) + + expect(value_from_redis(:failure_count).to_i).to eq(1) + expect(value_from_redis(:last_failure)).not_to be_empty + expect(circuit_breaker.failure_count).to eq(1) + expect(circuit_breaker.last_failure).to be_within(1.second).of(Time.now) + end + end end end @@ -158,183 +256,40 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state: expect(circuit_breaker.circuit_broken?).to be_falsey end - it 'is broken when there was a recent failure' do - Timecop.freeze do - set_in_redis(:last_failure, 1.second.ago.to_f) - set_in_redis(:failure_count, 1) - - expect(circuit_breaker.circuit_broken?).to be_truthy - end - end - it 'is broken when there are too many failures' do set_in_redis(:last_failure, 1.day.ago.to_f) set_in_redis(:failure_count, 200) expect(circuit_breaker.circuit_broken?).to be_truthy end + end + + describe '#backing_off?' do + it 'is true when there was a recent failure' do + Timecop.freeze do + set_in_redis(:last_failure, 1.second.ago.to_f) + set_in_redis(:failure_count, 90) + + expect(circuit_breaker.backing_off?).to be_truthy + end + end context 'the `failure_wait_time` is set to 0' do before do stub_application_setting(circuitbreaker_failure_wait_time: 0) end - it 'is working even when there is a recent failure' do + it 'is working even when there are failures' do Timecop.freeze do set_in_redis(:last_failure, 0.seconds.ago.to_f) - set_in_redis(:failure_count, 1) + set_in_redis(:failure_count, 90) - expect(circuit_breaker.circuit_broken?).to be_falsey + expect(circuit_breaker.backing_off?).to be_falsey end end end end - describe "storage_available?" do - context 'the storage is available' do - it 'tracks that the storage was accessible an raises the error' do - expect(circuit_breaker).to receive(:track_storage_accessible) - - circuit_breaker.storage_available? - end - - it 'only performs the check once' do - expect(Gitlab::Git::Storage::ForkedStorageCheck) - .to receive(:storage_available?).once.and_call_original - - 2.times { circuit_breaker.storage_available? } - end - end - - context 'storage is not available' do - let(:storage_name) { 'broken' } - - it 'tracks that the storage was inaccessible' do - expect(circuit_breaker).to receive(:track_storage_inaccessible) - - circuit_breaker.storage_available? - end - end - end - - describe '#check_storage_accessible!' do - it 'raises an exception with retry time when the circuit is open' do - allow(circuit_breaker).to receive(:circuit_broken?).and_return(true) - - expect { circuit_breaker.check_storage_accessible! } - .to raise_error do |exception| - expect(exception).to be_kind_of(Gitlab::Git::Storage::CircuitOpen) - expect(exception.retry_after).to eq(30) - end - end - - context 'the storage is not available' do - let(:storage_name) { 'broken' } - - it 'raises an error' do - expect(circuit_breaker).to receive(:track_storage_inaccessible) - - expect { circuit_breaker.check_storage_accessible! } - .to raise_error do |exception| - expect(exception).to be_kind_of(Gitlab::Git::Storage::Inaccessible) - expect(exception.retry_after).to eq(30) - end - end - end - end - - describe '#track_storage_inaccessible' do - around do |example| - Timecop.freeze { example.run } - end - - it 'records the failure time in redis' do - circuit_breaker.track_storage_inaccessible - - failure_time = value_from_redis(:last_failure) - - expect(Time.at(failure_time.to_i)).to be_within(1.second).of(Time.now) - end - - it 'sets the failure time on the breaker without reloading' do - circuit_breaker.track_storage_inaccessible - - expect(circuit_breaker).not_to receive(:get_failure_info) - expect(circuit_breaker.last_failure).to eq(Time.now) - end - - it 'increments the failure count in redis' do - set_in_redis(:failure_count, 10) - - circuit_breaker.track_storage_inaccessible - - expect(value_from_redis(:failure_count).to_i).to be(11) - end - - it 'increments the failure count on the breaker without reloading' do - set_in_redis(:failure_count, 10) - - circuit_breaker.track_storage_inaccessible - - expect(circuit_breaker).not_to receive(:get_failure_info) - expect(circuit_breaker.failure_count).to eq(11) - end - end - - describe '#track_storage_accessible' do - it 'sets the failure count to zero in redis' do - set_in_redis(:failure_count, 10) - - circuit_breaker.track_storage_accessible - - expect(value_from_redis(:failure_count).to_i).to be(0) - end - - it 'sets the failure count to zero on the breaker without reloading' do - set_in_redis(:failure_count, 10) - - circuit_breaker.track_storage_accessible - - expect(circuit_breaker).not_to receive(:get_failure_info) - expect(circuit_breaker.failure_count).to eq(0) - end - - it 'removes the last failure time from redis' do - set_in_redis(:last_failure, Time.now.to_i) - - circuit_breaker.track_storage_accessible - - expect(circuit_breaker).not_to receive(:get_failure_info) - expect(circuit_breaker.last_failure).to be_nil - end - - it 'removes the last failure time from the breaker without reloading' do - set_in_redis(:last_failure, Time.now.to_i) - - circuit_breaker.track_storage_accessible - - expect(value_from_redis(:last_failure)).to be_empty - end - - it 'wont connect to redis when there are no failures' do - expect(Gitlab::Git::Storage.redis).to receive(:with).once - .and_call_original - expect(circuit_breaker).to receive(:track_storage_accessible) - .and_call_original - - circuit_breaker.track_storage_accessible - end - end - - describe '#no_failures?' do - it 'is false when a failure was tracked' do - set_in_redis(:last_failure, Time.now.to_i) - set_in_redis(:failure_count, 1) - - expect(circuit_breaker.no_failures?).to be_falsey - end - end - describe '#last_failure' do it 'returns the last failure time' do time = Time.parse("2017-05-26 17:52:30") @@ -351,10 +306,4 @@ describe Gitlab::Git::Storage::CircuitBreaker, clean_gitlab_redis_shared_state: expect(circuit_breaker.failure_count).to eq(7) end end - - describe '#cache_key' do - it 'includes storage and host' do - expect(circuit_breaker.cache_key).to eq(cache_key) - end - end end diff --git a/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb b/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb index c708b15853a..39a5d020bb4 100644 --- a/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb +++ b/spec/lib/gitlab/git/storage/forked_storage_check_spec.rb @@ -33,6 +33,21 @@ describe Gitlab::Git::Storage::ForkedStorageCheck, broken_storage: true, skip_da expect(runtime).to be < 1.0 end + it 'will try the specified amount of times before failing' do + allow(described_class).to receive(:check_filesystem_in_process) do + Process.spawn("sleep 10") + end + + expect(Process).to receive(:spawn).with('sleep 10').twice + .and_call_original + + runtime = Benchmark.realtime do + described_class.storage_available?(existing_path, 0.5, 2) + end + + expect(runtime).to be < 1.0 + end + describe 'when using paths with spaces' do let(:test_dir) { Rails.root.join('tmp', 'tests', 'storage_check') } let(:path_with_spaces) { File.join(test_dir, 'path with spaces') } diff --git a/spec/lib/gitlab/git/storage/null_circuit_breaker_spec.rb b/spec/lib/gitlab/git/storage/null_circuit_breaker_spec.rb index 7ee6d2f3709..5db37f55e03 100644 --- a/spec/lib/gitlab/git/storage/null_circuit_breaker_spec.rb +++ b/spec/lib/gitlab/git/storage/null_circuit_breaker_spec.rb @@ -65,17 +65,6 @@ describe Gitlab::Git::Storage::NullCircuitBreaker do ours = described_class.public_instance_methods theirs = Gitlab::Git::Storage::CircuitBreaker.public_instance_methods - # These methods are not part of the public API, but are public to allow the - # CircuitBreaker specs to operate. They should be made private over time. - exceptions = %i[ - cache_key - check_storage_accessible! - no_failures? - storage_available? - track_storage_accessible - track_storage_inaccessible - ] - - expect(theirs - ours).to contain_exactly(*exceptions) + expect(theirs - ours).to be_empty end end diff --git a/spec/lib/gitlab/git/user_spec.rb b/spec/lib/gitlab/git/user_spec.rb index 31d5f59a562..eb8db819045 100644 --- a/spec/lib/gitlab/git/user_spec.rb +++ b/spec/lib/gitlab/git/user_spec.rb @@ -5,14 +5,20 @@ describe Gitlab::Git::User do let(:name) { 'Jane Doe' } let(:email) { 'janedoe@example.com' } let(:gl_id) { 'user-123' } + let(:user) do + described_class.new(username, name, email, gl_id) + end subject { described_class.new(username, name, email, gl_id) } describe '.from_gitaly' do - let(:gitaly_user) { Gitaly::User.new(name: name, email: email, gl_id: gl_id) } + let(:gitaly_user) do + Gitaly::User.new(gl_username: username, name: name, email: email, gl_id: gl_id) + end + subject { described_class.from_gitaly(gitaly_user) } - it { expect(subject).to eq(described_class.new('', name, email, gl_id)) } + it { expect(subject).to eq(user) } end describe '.from_gitlab' do @@ -35,4 +41,16 @@ describe Gitlab::Git::User do it { expect(subject).not_to eq_other(username, name, email + 'x', gl_id) } it { expect(subject).not_to eq_other(username, name, email, gl_id + 'x') } end + + describe '#to_gitaly' do + subject { user.to_gitaly } + + it 'creates a Gitaly::User with the correct data' do + expect(subject).to be_a(Gitaly::User) + expect(subject.gl_username).to eq(username) + expect(subject.name).to eq(name) + expect(subject.email).to eq(email) + expect(subject.gl_id).to eq(gl_id) + end + end end diff --git a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb index 7bd6a7fa842..e144e28b5d8 100644 --- a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb @@ -5,7 +5,7 @@ describe Gitlab::GitalyClient::OperationService do let(:repository) { project.repository.raw } let(:client) { described_class.new(repository) } let(:user) { create(:user) } - let(:gitaly_user) { Gitlab::GitalyClient::Util.gitaly_user(user) } + let(:gitaly_user) { Gitlab::Git::User.from_gitlab(user).to_gitaly } describe '#user_create_branch' do let(:branch_name) { 'new' } diff --git a/spec/lib/gitlab/gitaly_client/util_spec.rb b/spec/lib/gitlab/gitaly_client/util_spec.rb index c0c29552494..d1e0136f8c1 100644 --- a/spec/lib/gitlab/gitaly_client/util_spec.rb +++ b/spec/lib/gitlab/gitaly_client/util_spec.rb @@ -26,18 +26,4 @@ describe Gitlab::GitalyClient::Util do expect(subject.git_alternate_object_directories).to eq(git_alternate_object_directory) end end - - describe '.gitaly_user' do - let(:user) { create(:user) } - let(:gl_id) { Gitlab::GlId.gl_id(user) } - - subject { described_class.gitaly_user(user) } - - it 'creates a Gitaly::User from a GitLab user' do - expect(subject).to be_a(Gitaly::User) - expect(subject.name).to eq(user.name) - expect(subject.email).to eq(user.email) - expect(subject.gl_id).to eq(gl_id) - end - end end diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 30495fd4f5e..47b7150d36f 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -115,7 +115,8 @@ describe ApplicationSetting do end context 'circuitbreaker settings' do - [:circuitbreaker_failure_count_threshold, + [:circuitbreaker_backoff_threshold, + :circuitbreaker_failure_count_threshold, :circuitbreaker_failure_wait_time, :circuitbreaker_failure_reset_time, :circuitbreaker_storage_timeout].each do |field| @@ -125,6 +126,16 @@ describe ApplicationSetting do .is_greater_than_or_equal_to(0) end end + + it 'requires the `backoff_threshold` to be lower than the `failure_count_threshold`' do + setting.circuitbreaker_failure_count_threshold = 10 + setting.circuitbreaker_backoff_threshold = 15 + failure_message = "The circuitbreaker backoff threshold should be lower "\ + "than the failure count threshold" + + expect(setting).not_to be_valid + expect(setting.errors[:circuitbreaker_backoff_threshold]).to include(failure_message) + end end context 'repository storages' do diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 25e5d155894..e1be23541e8 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -575,6 +575,16 @@ describe Environment do end end + describe '#ref_path' do + subject(:environment) do + create(:environment, name: 'staging / review-1') + end + + it 'returns a path that uses the slug and does not have spaces' do + expect(environment.ref_path).to start_with('refs/environments/staging-review-1-') + end + end + describe '#external_url_for' do let(:source_path) { 'source/file.html' } let(:sha) { RepoHelpers.sample_commit.id } diff --git a/spec/models/instance_configuration_spec.rb b/spec/models/instance_configuration_spec.rb new file mode 100644 index 00000000000..8548fff5c76 --- /dev/null +++ b/spec/models/instance_configuration_spec.rb @@ -0,0 +1,109 @@ +require 'spec_helper' + +RSpec.describe InstanceConfiguration do + context 'without cache' do + describe '#settings' do + describe '#ssh_algorithms_hashes' do + let(:md5) { '54:e0:f8:70:d6:4f:4c:b1:b3:02:44:77:cf:cd:0d:fc' } + let(:sha256) { '9327f0d15a48c4d9f6a3aee65a1825baf9a3412001c98169c5fd022ac27762fc' } + + it 'does not return anything if file does not exist' do + stub_pub_file(exist: false) + + expect(subject.settings[:ssh_algorithms_hashes]).to be_empty + end + + it 'does not return anything if file is empty' do + stub_pub_file + + allow(File).to receive(:read).and_return('') + + expect(subject.settings[:ssh_algorithms_hashes]).to be_empty + end + + it 'returns the md5 and sha256 if file valid and exists' do + stub_pub_file + + result = subject.settings[:ssh_algorithms_hashes].select { |o| o[:md5] == md5 && o[:sha256] == sha256 } + + expect(result.size).to eq(InstanceConfiguration::SSH_ALGORITHMS.size) + end + + def stub_pub_file(exist: true) + path = 'spec/fixtures/ssh_host_example_key.pub' + path << 'random' unless exist + allow(subject).to receive(:ssh_algorithm_file).and_return(Rails.root.join(path)) + end + end + + describe '#host' do + it 'returns current instance host' do + allow(Settings.gitlab).to receive(:host).and_return('exampledomain') + + expect(subject.settings[:host]).to eq(Settings.gitlab.host) + end + end + + describe '#gitlab_pages' do + let(:gitlab_pages) { subject.settings[:gitlab_pages] } + it 'returns Settings.pages' do + gitlab_pages.delete(:ip_address) + + expect(gitlab_pages).to eq(Settings.pages.symbolize_keys) + end + + it 'returns the Gitlab\'s pages host ip address' do + expect(gitlab_pages.keys).to include(:ip_address) + end + + it 'returns the ip address as nil if the domain is invalid' do + allow(Settings.pages).to receive(:host).and_return('exampledomain') + + expect(gitlab_pages[:ip_address]).to eq nil + end + + it 'returns the ip address of the domain' do + allow(Settings.pages).to receive(:host).and_return('localhost') + + expect(gitlab_pages[:ip_address]).to eq('127.0.0.1').or eq('::1') + end + end + + describe '#gitlab_ci' do + let(:gitlab_ci) { subject.settings[:gitlab_ci] } + it 'returns Settings.gitalb_ci' do + gitlab_ci.delete(:artifacts_max_size) + + expect(gitlab_ci).to eq(Settings.gitlab_ci.symbolize_keys) + end + + it 'returns the key artifacts_max_size' do + expect(gitlab_ci.keys).to include(:artifacts_max_size) + end + end + end + end + + context 'with cache', :use_clean_rails_memory_store_caching do + it 'caches settings content' do + expect(Rails.cache.read(described_class::CACHE_KEY)).to be_nil + + settings = subject.settings + + expect(Rails.cache.read(described_class::CACHE_KEY)).to eq(settings) + end + + describe 'cached settings' do + before do + subject.settings + end + + it 'expires after EXPIRATION_TIME' do + allow(Time).to receive(:now).and_return(Time.now + described_class::EXPIRATION_TIME) + Rails.cache.cleanup + + expect(Rails.cache.read(described_class::CACHE_KEY)).to eq(nil) + end + end + end +end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 73e038b61ed..2b8aa7cf9c3 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -86,7 +86,7 @@ describe MergeRequest do context 'when the target branch does not exist' do before do - project.repository.raw_repository.delete_branch(subject.target_branch) + project.repository.rm_branch(subject.author, subject.target_branch) end it 'returns nil' do @@ -1388,7 +1388,7 @@ describe MergeRequest do context 'when the target branch does not exist' do before do - subject.project.repository.raw_repository.delete_branch(subject.target_branch) + subject.project.repository.rm_branch(subject.author, subject.target_branch) end it 'returns nil' do diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index 63bf131cfc5..ad22fb2a386 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -24,6 +24,8 @@ describe JiraService do end it { is_expected.not_to validate_presence_of(:url) } + it { is_expected.not_to validate_presence_of(:username) } + it { is_expected.not_to validate_presence_of(:password) } end context 'validating urls' do @@ -54,6 +56,18 @@ describe JiraService do expect(service).not_to be_valid end + it 'is not valid when username is missing' do + service.username = nil + + expect(service).not_to be_valid + end + + it 'is not valid when password is missing' do + service.password = nil + + expect(service).not_to be_valid + end + it 'is valid when api url is a valid url' do service.api_url = 'http://jira.test.com/api' diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index 2298dcab55f..00de536a18b 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -99,8 +99,25 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do describe '#actual_namespace' do subject { service.actual_namespace } - it "returns the default namespace" do - is_expected.to eq(service.send(:default_namespace)) + shared_examples 'a correctly formatted namespace' do + it 'returns a valid Kubernetes namespace name' do + expect(subject).to match(Gitlab::Regex.kubernetes_namespace_regex) + expect(subject).to eq(expected_namespace) + end + end + + it_behaves_like 'a correctly formatted namespace' do + let(:expected_namespace) { service.send(:default_namespace) } + end + + context 'when the project path contains forbidden characters' do + before do + project.path = '-a_Strange.Path--forSure' + end + + it_behaves_like 'a correctly formatted namespace' do + let(:expected_namespace) { "a-strange-path--forsure-#{project.id}" } + end end context 'when namespace is specified' do @@ -108,8 +125,8 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do service.namespace = 'my-namespace' end - it "returns the user-namespace" do - is_expected.to eq('my-namespace') + it_behaves_like 'a correctly formatted namespace' do + let(:expected_namespace) { 'my-namespace' } end end @@ -118,35 +135,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do service.project = nil end - it "does not return namespace" do - is_expected.to be_nil - end - end - end - - describe '#actual_namespace' do - subject { service.actual_namespace } - - it "returns the default namespace" do - is_expected.to eq(service.send(:default_namespace)) - end - - context 'when namespace is specified' do - before do - service.namespace = 'my-namespace' - end - - it "returns the user-namespace" do - is_expected.to eq('my-namespace') - end - end - - context 'when service is not assigned to project' do - before do - service.project = nil - end - - it "does not return namespace" do + it 'does not return namespace' do is_expected.to be_nil end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 39d188f18af..d7c07676911 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -299,6 +299,24 @@ describe Repository do it { is_expected.to be_falsey } end + + context 'when pre-loaded merged branches are provided' do + using RSpec::Parameterized::TableSyntax + + where(:branch, :pre_loaded, :expected) do + 'not-merged-branch' | ['branch-merged'] | false + 'branch-merged' | ['not-merged-branch'] | false + 'branch-merged' | ['branch-merged'] | true + 'not-merged-branch' | ['not-merged-branch'] | false + 'master' | ['master'] | false + end + + with_them do + subject { repository.merged_to_root_ref?(branch, pre_loaded) } + + it { is_expected.to eq(expected) } + end + end end describe '#can_be_merged?' do @@ -2110,19 +2128,41 @@ describe Repository do end describe '#cache_method_output', :use_clean_rails_memory_store_caching do + let(:fallback) { 10 } + context 'with a non-existing repository' do - let(:value) do - repository.cache_method_output(:cats, fallback: 10) do - raise Rugged::ReferenceError + let(:project) { create(:project) } # No repository + + subject do + repository.cache_method_output(:cats, fallback: fallback) do + repository.cats_call_stub end end - it 'returns a fallback value' do - expect(value).to eq(10) + it 'returns the fallback value' do + expect(subject).to eq(fallback) + end + + it 'avoids calling the original method' do + expect(repository).not_to receive(:cats_call_stub) + + subject + end + end + + context 'with a method throwing a non-existing-repository error' do + subject do + repository.cache_method_output(:cats, fallback: fallback) do + raise Gitlab::Git::Repository::NoRepository + end + end + + it 'returns the fallback value' do + expect(subject).to eq(fallback) end it 'does not cache the data' do - value + subject expect(repository.instance_variable_defined?(:@cats)).to eq(false) expect(repository.send(:cache).exist?(:cats)).to eq(false) @@ -2238,4 +2278,24 @@ describe Repository do end end end + + describe 'commit cache' do + set(:project) { create(:project, :repository) } + + it 'caches based on SHA' do + # Gets the commit oid, and warms the cache + oid = project.commit.id + + expect(Gitlab::Git::Commit).not_to receive(:find).once + + project.commit_by(oid: oid) + end + + it 'caches nil values' do + expect(Gitlab::Git::Commit).to receive(:find).once + + project.commit_by(oid: '1' * 40) + project.commit_by(oid: '1' * 40) + end + end end diff --git a/spec/requests/api/access_requests_spec.rb b/spec/requests/api/access_requests_spec.rb index 50d0f72f6bc..35ca3635a9d 100644 --- a/spec/requests/api/access_requests_spec.rb +++ b/spec/requests/api/access_requests_spec.rb @@ -35,7 +35,7 @@ describe API::AccessRequests do user = public_send(type) get api("/#{source_type.pluralize}/#{source.id}/access_requests", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -45,7 +45,7 @@ describe API::AccessRequests do it 'returns access requesters' do get api("/#{source_type.pluralize}/#{source.id}/access_requests", master) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -68,7 +68,7 @@ describe API::AccessRequests do user = public_send(type) post api("/#{source_type.pluralize}/#{source.id}/access_requests", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end.not_to change { source.requesters.count } end end @@ -80,7 +80,7 @@ describe API::AccessRequests do expect do post api("/#{source_type.pluralize}/#{source.id}/access_requests", access_requester) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end.not_to change { source.requesters.count } end end @@ -95,7 +95,7 @@ describe API::AccessRequests do expect do post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end.not_to change { source.requesters.count } end end @@ -104,7 +104,7 @@ describe API::AccessRequests do expect do post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.requesters.count }.by(1) # User attributes @@ -135,7 +135,7 @@ describe API::AccessRequests do user = public_send(type) put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -147,7 +147,7 @@ describe API::AccessRequests do put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", master), access_level: Member::MASTER - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) # User attributes expect(json_response['id']).to eq(access_requester.id) @@ -166,7 +166,7 @@ describe API::AccessRequests do expect do put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}/approve", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end.not_to change { source.members.count } end end @@ -187,7 +187,7 @@ describe API::AccessRequests do user = public_send(type) delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -198,7 +198,7 @@ describe API::AccessRequests do expect do delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", access_requester) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { source.requesters.count }.by(-1) end end @@ -208,7 +208,7 @@ describe API::AccessRequests do expect do delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", master) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { source.requesters.count }.by(-1) end @@ -217,7 +217,7 @@ describe API::AccessRequests do expect do delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{developer.id}", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end.not_to change { source.requesters.count } end end @@ -227,7 +227,7 @@ describe API::AccessRequests do expect do delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end.not_to change { source.requesters.count } end end diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb index 7a0765c1fae..eaf12f71421 100644 --- a/spec/requests/api/award_emoji_spec.rb +++ b/spec/requests/api/award_emoji_spec.rb @@ -18,7 +18,7 @@ describe API::AwardEmoji do it "returns an array of award_emoji" do get api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(award_emoji.name) end @@ -26,7 +26,7 @@ describe API::AwardEmoji do it "returns a 404 error when issue id not found" do get api("/projects/#{project.id}/issues/12345/award_emoji", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -34,7 +34,7 @@ describe API::AwardEmoji do it "returns an array of award_emoji" do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['name']).to eq(downvote.name) @@ -48,7 +48,7 @@ describe API::AwardEmoji do it 'returns the awarded emoji' do get api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(award.name) end @@ -60,7 +60,7 @@ describe API::AwardEmoji do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -71,7 +71,7 @@ describe API::AwardEmoji do it 'returns an array of award emoji' do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(rocket.name) end @@ -82,7 +82,7 @@ describe API::AwardEmoji do it "returns the award emoji" do get api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/#{award_emoji.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(award_emoji.name) expect(json_response['awardable_id']).to eq(issue.id) expect(json_response['awardable_type']).to eq("Issue") @@ -91,7 +91,7 @@ describe API::AwardEmoji do it "returns a 404 error if the award is not found" do get api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -99,7 +99,7 @@ describe API::AwardEmoji do it 'returns the award emoji' do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(downvote.name) expect(json_response['awardable_id']).to eq(merge_request.id) expect(json_response['awardable_type']).to eq("MergeRequest") @@ -113,7 +113,7 @@ describe API::AwardEmoji do it 'returns the awarded emoji' do get api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(award.name) expect(json_response['awardable_id']).to eq(snippet.id) expect(json_response['awardable_type']).to eq("Snippet") @@ -126,7 +126,7 @@ describe API::AwardEmoji do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -137,7 +137,7 @@ describe API::AwardEmoji do it 'returns an award emoji' do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji/#{rocket.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).not_to be_an Array expect(json_response['name']).to eq(rocket.name) end @@ -150,7 +150,7 @@ describe API::AwardEmoji do it "creates a new award emoji" do post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'blowfish' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') expect(json_response['user']['username']).to eq(user.username) end @@ -158,19 +158,19 @@ describe API::AwardEmoji do it "returns a 400 bad request error if the name is not given" do post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if the user is not authenticated" do post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji"), name: 'thumbsup' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns a 404 error if the user authored issue" do post api("/projects/#{project.id}/issues/#{issue2.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "normalizes +1 as thumbsup award" do @@ -184,7 +184,7 @@ describe API::AwardEmoji do post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'thumbsup' post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") end end @@ -196,7 +196,7 @@ describe API::AwardEmoji do post api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user), name: 'blowfish' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') expect(json_response['user']['username']).to eq(user.username) end @@ -211,14 +211,14 @@ describe API::AwardEmoji do post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' end.to change { note.award_emoji.count }.from(0).to(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['user']['username']).to eq(user.username) end it "it returns 404 error when user authored note" do post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note2.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "normalizes +1 as thumbsup award" do @@ -232,7 +232,7 @@ describe API::AwardEmoji do post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), name: 'rocket' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") end end @@ -244,14 +244,14 @@ describe API::AwardEmoji do expect do delete api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/#{award_emoji.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { issue.award_emoji.count }.from(1).to(0) end it 'returns a 404 error when the award emoji can not be found' do delete api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -264,14 +264,14 @@ describe API::AwardEmoji do expect do delete api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { merge_request.award_emoji.count }.from(1).to(0) end it 'returns a 404 error when note id not found' do delete api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -287,7 +287,7 @@ describe API::AwardEmoji do expect do delete api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { snippet.award_emoji.count }.from(1).to(0) end @@ -304,7 +304,7 @@ describe API::AwardEmoji do expect do delete api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji/#{rocket.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { note.award_emoji.count }.from(1).to(0) end diff --git a/spec/requests/api/boards_spec.rb b/spec/requests/api/boards_spec.rb index fcfa4ddfbfe..546a1697e56 100644 --- a/spec/requests/api/boards_spec.rb +++ b/spec/requests/api/boards_spec.rb @@ -44,7 +44,7 @@ describe API::Boards do it "returns authentication error" do get api(base_url) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -52,7 +52,7 @@ describe API::Boards do it "returns the project issue board" do get api(base_url, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -70,7 +70,7 @@ describe API::Boards do it 'returns issue board lists' do get api(base_url, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(2) @@ -80,7 +80,7 @@ describe API::Boards do it 'returns 404 if board not found' do get api("/projects/#{project.id}/boards/22343/lists", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -90,7 +90,7 @@ describe API::Boards do it 'returns a list' do get api("#{base_url}/#{dev_list.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(dev_list.id) expect(json_response['label']['name']).to eq(dev_label.title) expect(json_response['position']).to eq(1) @@ -99,7 +99,7 @@ describe API::Boards do it 'returns 404 if list not found' do get api("#{base_url}/5324", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -113,7 +113,7 @@ describe API::Boards do post api(base_url, user), label_id: group_label.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['label']['name']).to eq(group_label.title) expect(json_response['position']).to eq(3) end @@ -121,7 +121,7 @@ describe API::Boards do it 'creates a new issue board list for project labels' do post api(base_url, user), label_id: ux_label.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['label']['name']).to eq(ux_label.title) expect(json_response['position']).to eq(3) end @@ -129,13 +129,13 @@ describe API::Boards do it 'returns 400 when creating a new list if label_id is invalid' do post api(base_url, user), label_id: 23423 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 403 for project members with guest role' do put api("#{base_url}/#{test_list.id}", guest), position: 1 - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -146,7 +146,7 @@ describe API::Boards do put api("#{base_url}/#{test_list.id}", user), position: 1 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['position']).to eq(1) end @@ -154,14 +154,14 @@ describe API::Boards do put api("#{base_url}/44444", user), position: 1 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 403 for project members with guest role" do put api("#{base_url}/#{test_list.id}", guest), position: 1 - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -171,19 +171,19 @@ describe API::Boards do it "rejects a non member from deleting a list" do delete api("#{base_url}/#{dev_list.id}", non_member) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "rejects a user with guest role from deleting a list" do delete api("#{base_url}/#{dev_list.id}", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 404 error if list id not found" do delete api("#{base_url}/44444", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when the user is project owner" do @@ -196,7 +196,7 @@ describe API::Boards do it "deletes the list if an admin requests it" do delete api("#{base_url}/#{dev_list.id}", owner) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it_behaves_like '412 response' do diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb index eacc575d97f..fe8a14fae9e 100644 --- a/spec/requests/api/broadcast_messages_spec.rb +++ b/spec/requests/api/broadcast_messages_spec.rb @@ -9,13 +9,13 @@ describe API::BroadcastMessages do it 'returns a 401 for anonymous users' do get api('/broadcast_messages') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do get api('/broadcast_messages', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns an Array of BroadcastMessages for admins' do @@ -23,7 +23,7 @@ describe API::BroadcastMessages do get api('/broadcast_messages', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_kind_of(Array) expect(json_response.first.keys) @@ -35,19 +35,19 @@ describe API::BroadcastMessages do it 'returns a 401 for anonymous users' do get api("/broadcast_messages/#{message.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do get api("/broadcast_messages/#{message.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns the specified message for admins' do get api("/broadcast_messages/#{message.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq message.id expect(json_response.keys) .to match_array(%w(id message starts_at ends_at color font active)) @@ -58,13 +58,13 @@ describe API::BroadcastMessages do it 'returns a 401 for anonymous users' do post api('/broadcast_messages'), attributes_for(:broadcast_message) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do post api('/broadcast_messages', user), attributes_for(:broadcast_message) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'as an admin' do @@ -74,7 +74,7 @@ describe API::BroadcastMessages do post api('/broadcast_messages', admin), attrs - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'message is missing' end @@ -83,7 +83,7 @@ describe API::BroadcastMessages do travel_to(time) do post api('/broadcast_messages', admin), message: 'Test message' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z' expect(json_response['ends_at']).to eq '2016-07-02T11:11:12.000Z' end @@ -94,7 +94,7 @@ describe API::BroadcastMessages do post api('/broadcast_messages', admin), attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['color']).to eq attrs[:color] expect(json_response['font']).to eq attrs[:font] end @@ -106,14 +106,14 @@ describe API::BroadcastMessages do put api("/broadcast_messages/#{message.id}"), attributes_for(:broadcast_message) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do put api("/broadcast_messages/#{message.id}", user), attributes_for(:broadcast_message) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'as an admin' do @@ -122,7 +122,7 @@ describe API::BroadcastMessages do put api("/broadcast_messages/#{message.id}", admin), attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['color']).to eq attrs[:color] expect(json_response['font']).to eq attrs[:font] end @@ -134,7 +134,7 @@ describe API::BroadcastMessages do put api("/broadcast_messages/#{message.id}", admin), attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z' expect(json_response['ends_at']).to eq '2016-07-02T13:11:12.000Z' end @@ -145,7 +145,7 @@ describe API::BroadcastMessages do put api("/broadcast_messages/#{message.id}", admin), attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect { message.reload }.to change { message.message }.to('new message') end end @@ -156,14 +156,14 @@ describe API::BroadcastMessages do delete api("/broadcast_messages/#{message.id}"), attributes_for(:broadcast_message) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do delete api("/broadcast_messages/#{message.id}", user), attributes_for(:broadcast_message) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it_behaves_like '412 response' do @@ -174,7 +174,7 @@ describe API::BroadcastMessages do expect do delete api("/broadcast_messages/#{message.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { BroadcastMessage.count }.by(-1) end end diff --git a/spec/requests/api/circuit_breakers_spec.rb b/spec/requests/api/circuit_breakers_spec.rb index 76521e55994..3b858c40fd6 100644 --- a/spec/requests/api/circuit_breakers_spec.rb +++ b/spec/requests/api/circuit_breakers_spec.rb @@ -8,13 +8,13 @@ describe API::CircuitBreakers do it 'returns a 401 for anonymous users' do get api('/circuit_breakers/repository_storage') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do get api('/circuit_breakers/repository_storage', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns an Array of storages' do @@ -24,7 +24,7 @@ describe API::CircuitBreakers do get api('/circuit_breakers/repository_storage', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_kind_of(Array) expect(json_response.first['storage_name']).to eq('broken') expect(json_response.first['failing_on_hosts']).to eq(['web01']) @@ -39,7 +39,7 @@ describe API::CircuitBreakers do get api('/circuit_breakers/repository_storage/failing', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_kind_of(Array) end end @@ -51,7 +51,7 @@ describe API::CircuitBreakers do delete api('/circuit_breakers/repository_storage', admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end end end diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index e4c73583545..ffa17d296e8 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -39,7 +39,7 @@ describe API::CommitStatuses do end it 'returns latest commit statuses' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array @@ -55,7 +55,7 @@ describe API::CommitStatuses do end it 'returns all commit statuses' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(statuses_id).to contain_exactly(status1.id, status2.id, @@ -70,7 +70,7 @@ describe API::CommitStatuses do end it 'returns latest commit statuses for specific ref' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(statuses_id).to contain_exactly(status3.id, status5.id) @@ -83,7 +83,7 @@ describe API::CommitStatuses do end it 'return latest commit statuses for specific name' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(statuses_id).to contain_exactly(status4.id, status5.id) @@ -110,7 +110,7 @@ describe API::CommitStatuses do end it "does not return project commits" do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -120,7 +120,7 @@ describe API::CommitStatuses do end it "does not return project commits" do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -135,7 +135,7 @@ describe API::CommitStatuses do it 'creates commit status' do post api(post_url, developer), state: status - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq(status) expect(json_response['name']).to eq('default') @@ -159,7 +159,7 @@ describe API::CommitStatuses do it "to #{status}" do expect { post api(post_url, developer), state: status }.not_to change { CommitStatus.count } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['status']).to eq(status) end end @@ -181,7 +181,7 @@ describe API::CommitStatuses do it 'creates commit status' do subject - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') expect(json_response['name']).to eq('coverage') @@ -197,7 +197,7 @@ describe API::CommitStatuses do it 'sets head pipeline' do subject - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(merge_request.reload.head_pipeline).not_to be_nil end end @@ -224,7 +224,7 @@ describe API::CommitStatuses do end it 'updates a commit status' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') expect(json_response['name']).to eq('coverage') @@ -250,7 +250,7 @@ describe API::CommitStatuses do end it 'correctly posts a new commit status' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['sha']).to eq(commit.id) expect(json_response['status']).to eq('success') end @@ -268,7 +268,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -278,7 +278,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -290,7 +290,7 @@ describe API::CommitStatuses do end it 'returns not found error' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -301,7 +301,7 @@ describe API::CommitStatuses do end it 'responds with bad request status and validation errors' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['target_url']) .to include 'must be a valid URL' end @@ -314,7 +314,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -324,7 +324,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -334,7 +334,7 @@ describe API::CommitStatuses do end it 'does not create commit status' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb index 94462b4572d..0d2bd3207c0 100644 --- a/spec/requests/api/commits_spec.rb +++ b/spec/requests/api/commits_spec.rb @@ -24,7 +24,7 @@ describe API::Commits do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/commits') expect(json_response.first['id']).to eq(commit.id) expect(json_response.first['committer_name']).to eq(commit.committer_name) @@ -119,7 +119,7 @@ describe API::Commits do it "returns an invalid parameter error message" do get api("/projects/#{project_id}/repository/commits?since=invalid-date", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('since is invalid') end end @@ -198,13 +198,13 @@ describe API::Commits do it 'returns a 403 unauthorized for user without permissions' do post api(url, guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns a 400 bad request if no params are given' do post api(url, user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end describe 'create' do @@ -248,7 +248,7 @@ describe API::Commits do it 'returns a 400 bad request if file exists' do post api(url, user), invalid_c_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'with project path containing a dot in URL' do @@ -257,7 +257,7 @@ describe API::Commits do it 'a new file in project repo' do post api(url, user), valid_c_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end end @@ -292,14 +292,14 @@ describe API::Commits do it 'an existing file in project repo' do post api(url, user), valid_d_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post api(url, user), invalid_d_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -337,14 +337,14 @@ describe API::Commits do it 'an existing file in project repo' do post api(url, user), valid_m_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post api(url, user), invalid_m_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -380,14 +380,14 @@ describe API::Commits do it 'an existing file in project repo' do post api(url, user), valid_u_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post api(url, user), invalid_u_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -453,14 +453,14 @@ describe API::Commits do it 'are commited as one in project repo' do post api(url, user), valid_mo_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'return a 400 bad request if there are any issues' do post api(url, user), invalid_mo_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -571,7 +571,7 @@ describe API::Commits do it 'includes a "created" status' do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/commit/detail') expect(json_response['status']).to eq('created') expect(json_response['last_pipeline']['id']).to eq(pipeline.id) @@ -588,7 +588,7 @@ describe API::Commits do it 'includes a "success" status' do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/commit/detail') expect(json_response['status']).to eq('success') end diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb index 684877c33c0..1f1e6ea17e4 100644 --- a/spec/requests/api/deploy_keys_spec.rb +++ b/spec/requests/api/deploy_keys_spec.rb @@ -48,7 +48,7 @@ describe API::DeployKeys do it 'returns array of ssh keys' do get api("/projects/#{project.id}/deploy_keys", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['title']).to eq(deploy_key.title) @@ -59,14 +59,14 @@ describe API::DeployKeys do it 'returns a single key' do get api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(deploy_key.title) end it 'returns 404 Not Found with invalid ID' do get api("/projects/#{project.id}/deploy_keys/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -74,14 +74,14 @@ describe API::DeployKeys do it 'does not create an invalid ssh key' do post api("/projects/#{project.id}/deploy_keys", admin), { title: 'invalid key' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create a key without title' do post api("/projects/#{project.id}/deploy_keys", admin), key: 'some key' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end @@ -98,7 +98,7 @@ describe API::DeployKeys do post api("/projects/#{project.id}/deploy_keys", admin), { key: deploy_key.key, title: deploy_key.title } end.not_to change { project.deploy_keys.count } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'joins an existing ssh key to a new project' do @@ -106,7 +106,7 @@ describe API::DeployKeys do post api("/projects/#{project2.id}/deploy_keys", admin), { key: deploy_key.key, title: deploy_key.title } end.to change { project2.deploy_keys.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'accepts can_push parameter' do @@ -114,7 +114,7 @@ describe API::DeployKeys do post api("/projects/#{project.id}/deploy_keys", admin), key_attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['can_push']).to eq(true) end end @@ -130,7 +130,7 @@ describe API::DeployKeys do put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin), { title: 'new title' } end.not_to change(deploy_key, :title) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not update a public deploy key as non admin' do @@ -138,7 +138,7 @@ describe API::DeployKeys do put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", user), { title: 'new title' } end.not_to change(deploy_key, :title) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not update a private key with invalid title' do @@ -148,7 +148,7 @@ describe API::DeployKeys do put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), { title: '' } end.not_to change(deploy_key, :title) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'updates a private ssh key with correct attributes' do @@ -181,14 +181,14 @@ describe API::DeployKeys do expect do delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { project.deploy_keys.count }.by(-1) end it 'returns 404 Not Found with invalid ID' do delete api("/projects/#{project.id}/deploy_keys/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -205,7 +205,7 @@ describe API::DeployKeys do post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", admin) end.to change { project2.deploy_keys.count }.from(0).to(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(deploy_key.id) end end @@ -214,7 +214,7 @@ describe API::DeployKeys do it 'returns a 404 error' do post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/deployments_spec.rb b/spec/requests/api/deployments_spec.rb index 90d78d060ca..c7977e624ff 100644 --- a/spec/requests/api/deployments_spec.rb +++ b/spec/requests/api/deployments_spec.rb @@ -15,7 +15,7 @@ describe API::Deployments do it 'returns projects deployments' do get api("/projects/#{project.id}/deployments", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -28,7 +28,7 @@ describe API::Deployments do it 'returns a 404 status code' do get api("/projects/#{project.id}/deployments", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -38,7 +38,7 @@ describe API::Deployments do it 'returns the projects deployment' do get api("/projects/#{project.id}/deployments/#{deployment.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['sha']).to match /\A\h{40}\z/ expect(json_response['id']).to eq(deployment.id) end @@ -48,7 +48,7 @@ describe API::Deployments do it 'returns a 404 status code' do get api("/projects/#{project.id}/deployments/#{deployment.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/doorkeeper_access_spec.rb b/spec/requests/api/doorkeeper_access_spec.rb index 868fef65c1c..de7ce848a31 100644 --- a/spec/requests/api/doorkeeper_access_spec.rb +++ b/spec/requests/api/doorkeeper_access_spec.rb @@ -8,7 +8,7 @@ describe 'doorkeeper access' do describe "unauthenticated" do it "returns authentication success" do get api("/user"), access_token: token.token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end include_examples 'user login request with unique ip limit' do @@ -21,14 +21,14 @@ describe 'doorkeeper access' do describe "when token invalid" do it "returns authentication error" do get api("/user"), access_token: "123a" - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end describe "authorization by private token" do it "returns authentication success" do get api("/user", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end include_examples 'user login request with unique ip limit' do @@ -43,7 +43,7 @@ describe 'doorkeeper access' do user.block get api("/user"), access_token: token.token - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -52,7 +52,7 @@ describe 'doorkeeper access' do user.ldap_block get api("/user"), access_token: token.token - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb index f8cd529a06c..3665cfd7241 100644 --- a/spec/requests/api/environments_spec.rb +++ b/spec/requests/api/environments_spec.rb @@ -25,7 +25,7 @@ describe API::Environments do get api("/projects/#{project.id}/environments", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -39,7 +39,7 @@ describe API::Environments do it 'returns a 404 status code' do get api("/projects/#{project.id}/environments", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -49,7 +49,7 @@ describe API::Environments do it 'creates a environment with valid params' do post api("/projects/#{project.id}/environments", user), name: "mepmep" - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('mepmep') expect(json_response['slug']).to eq('mepmep') expect(json_response['external']).to be nil @@ -58,19 +58,19 @@ describe API::Environments do it 'requires name to be passed' do post api("/projects/#{project.id}/environments", user), external_url: 'test.gitlab.com' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if environment already exists' do post api("/projects/#{project.id}/environments", user), name: environment.name - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if slug is specified' do post api("/projects/#{project.id}/environments", user), name: "foo", slug: "foo" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") end end @@ -79,7 +79,7 @@ describe API::Environments do it 'rejects the request' do post api("/projects/#{project.id}/environments", non_member), name: 'gitlab.com' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 400 when the required params are missing' do @@ -94,7 +94,7 @@ describe API::Environments do put api("/projects/#{project.id}/environments/#{environment.id}", user), name: 'Mepmep', external_url: url - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') expect(json_response['external_url']).to eq(url) end @@ -104,7 +104,7 @@ describe API::Environments do api_url = api("/projects/#{project.id}/environments/#{environment.id}", user) put api_url, slug: slug + "-foo" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") end @@ -113,7 +113,7 @@ describe API::Environments do put api("/projects/#{project.id}/environments/#{environment.id}", user), name: 'Mepmep' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') expect(json_response['external_url']).to eq(url) end @@ -121,7 +121,7 @@ describe API::Environments do it 'returns a 404 if the environment does not exist' do put api("/projects/#{project.id}/environments/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -130,13 +130,13 @@ describe API::Environments do it 'returns a 200 for an existing environment' do delete api("/projects/#{project.id}/environments/#{environment.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'returns a 404 for non existing id' do delete api("/projects/#{project.id}/environments/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end @@ -149,7 +149,7 @@ describe API::Environments do it 'rejects the request' do delete api("/projects/#{project.id}/environments/#{environment.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -164,7 +164,7 @@ describe API::Environments do end it 'returns a 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'actually stops the environment' do @@ -175,7 +175,7 @@ describe API::Environments do it 'returns a 404 for non existing id' do post api("/projects/#{project.id}/environments/12345/stop", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end end @@ -184,7 +184,7 @@ describe API::Environments do it 'rejects the request' do post api("/projects/#{project.id}/environments/#{environment.id}/stop", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/events_spec.rb b/spec/requests/api/events_spec.rb index a23d28994ce..962c845f36d 100644 --- a/spec/requests/api/events_spec.rb +++ b/spec/requests/api/events_spec.rb @@ -14,7 +14,7 @@ describe API::Events do it 'returns authentication error' do get api('/events') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -22,7 +22,7 @@ describe API::Events do it 'returns users events' do get api('/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -35,7 +35,7 @@ describe API::Events do it 'returns no events' do get api("/users/#{user.id}/events", other_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -44,7 +44,7 @@ describe API::Events do it 'accepts a username' do get api("/users/#{user.username}/events", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -53,7 +53,7 @@ describe API::Events do it 'returns the events' do get api("/users/#{user.id}/events", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -72,7 +72,7 @@ describe API::Events do end it 'responds with HTTP 200 OK' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'includes the push payload as a Hash' do @@ -120,7 +120,7 @@ describe API::Events do it 'returns a 404 error if not found' do get api('/users/42/events', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end end @@ -130,7 +130,7 @@ describe API::Events do it 'returns 404 for private project' do get api("/projects/#{private_project.id}/events") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 200 status for a public project' do @@ -138,7 +138,7 @@ describe API::Events do get api("/projects/#{public_project.id}/events") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -146,7 +146,7 @@ describe API::Events do it 'returns 404' do get api("/projects/#{private_project.id}/events", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -154,7 +154,7 @@ describe API::Events do it 'returns project events' do get api("/projects/#{private_project.id}/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -163,7 +163,7 @@ describe API::Events do it 'returns 404 if project does not exist' do get api("/projects/1234/events", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index 7e21006b254..267058d98ee 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -44,19 +44,19 @@ describe API::Features do it 'returns a 401 for anonymous users' do get api('/features') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do get api('/features', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns the feature list for admins' do get api('/features', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to match_array(expected_features) end end @@ -68,20 +68,20 @@ describe API::Features do it 'returns a 401 for anonymous users' do post api("/features/#{feature_name}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do post api("/features/#{feature_name}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'when passed value=true' do it 'creates an enabled feature' do post api("/features/#{feature_name}", admin), value: 'true' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'on', @@ -91,7 +91,7 @@ describe API::Features do it 'creates an enabled feature for the given Flipper group when passed feature_group=perf_team' do post api("/features/#{feature_name}", admin), value: 'true', feature_group: 'perf_team' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -104,7 +104,7 @@ describe API::Features do it 'creates an enabled feature for the given user when passed user=username' do post api("/features/#{feature_name}", admin), value: 'true', user: user.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -117,7 +117,7 @@ describe API::Features do it 'creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team' do post api("/features/#{feature_name}", admin), value: 'true', user: user.username, feature_group: 'perf_team' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -132,7 +132,7 @@ describe API::Features do it 'creates a feature with the given percentage if passed an integer' do post api("/features/#{feature_name}", admin), value: '50' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -154,7 +154,7 @@ describe API::Features do it 'enables the feature' do post api("/features/#{feature_name}", admin), value: 'true' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'on', @@ -164,7 +164,7 @@ describe API::Features do it 'enables the feature for the given Flipper group when passed feature_group=perf_team' do post api("/features/#{feature_name}", admin), value: 'true', feature_group: 'perf_team' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -177,7 +177,7 @@ describe API::Features do it 'enables the feature for the given user when passed user=username' do post api("/features/#{feature_name}", admin), value: 'true', user: user.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', @@ -195,7 +195,7 @@ describe API::Features do post api("/features/#{feature_name}", admin), value: 'false' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'off', @@ -208,7 +208,7 @@ describe API::Features do post api("/features/#{feature_name}", admin), value: 'false', feature_group: 'perf_team' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'off', @@ -221,7 +221,7 @@ describe API::Features do post api("/features/#{feature_name}", admin), value: 'false', user: user.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'off', @@ -237,7 +237,7 @@ describe API::Features do it 'updates the percentage of time if passed an integer' do post api("/features/#{feature_name}", admin), value: '30' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to eq( 'name' => 'my_feature', 'state' => 'conditional', diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb index 114019441a3..5d8338a3fb7 100644 --- a/spec/requests/api/files_spec.rb +++ b/spec/requests/api/files_spec.rb @@ -26,7 +26,7 @@ describe API::Files do it 'returns file attributes as json' do get api(route(file_path), current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) expect(json_response['file_name']).to eq('popen.rb') expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') @@ -38,7 +38,7 @@ describe API::Files do get api(route(file_path), current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq('application/json') end @@ -49,7 +49,7 @@ describe API::Files do get api(route(file_path), current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_name']).to eq('commit.js.coffee') expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n") end @@ -60,7 +60,7 @@ describe API::Files do get api(url, current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when mandatory params are not given' do @@ -122,7 +122,7 @@ describe API::Files do get api(url, current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns raw file info for files with dots' do @@ -131,7 +131,7 @@ describe API::Files do get api(url, current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns file by commit sha' do @@ -142,7 +142,7 @@ describe API::Files do get api(route(file_path) + "/raw", current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when mandatory params are not given' do @@ -209,7 +209,7 @@ describe API::Files do it "creates a new file in project repo" do post api(route(file_path), user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["file_path"]).to eq(CGI.unescape(file_path)) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -219,7 +219,7 @@ describe API::Files do it "returns a 400 bad request if no mandatory params given" do post api(route("any%2Etxt"), user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 if editor fails to create file" do @@ -228,7 +228,7 @@ describe API::Files do post api(route("any%2Etxt"), user), valid_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -237,7 +237,7 @@ describe API::Files do post api(route("new_file_with_author%2Etxt"), user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(response.content_type).to eq('application/json') last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) @@ -251,7 +251,7 @@ describe API::Files do it "creates a new file in project repo" do post api(route("newfile%2Erb"), user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['file_path']).to eq('newfile.rb') last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -272,7 +272,7 @@ describe API::Files do it "updates existing file in project repo" do put api(route(file_path), user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -284,7 +284,7 @@ describe API::Files do put api(route(file_path), user), params_with_stale_id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('You are attempting to update a file that has changed since you started editing it.') end @@ -295,13 +295,13 @@ describe API::Files do put api(route(file_path), user), params_with_correct_id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns a 400 bad request if no params given" do put api(route(file_path), user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -310,7 +310,7 @@ describe API::Files do put api(route(file_path), user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) expect(last_commit.author_name).to eq(author_name) @@ -329,13 +329,13 @@ describe API::Files do it "deletes existing file in project repo" do delete api(route(file_path), user), valid_params - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it "returns a 400 bad request if no params given" do delete api(route(file_path), user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 if fails to delete file" do @@ -343,7 +343,7 @@ describe API::Files do delete api(route(file_path), user), valid_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -352,7 +352,7 @@ describe API::Files do delete api(route(file_path), user), valid_params - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end end end @@ -380,7 +380,7 @@ describe API::Files do it "remains unchanged" do get api(route(file_path), user), get_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(CGI.unescape(file_path)) expect(json_response['file_name']).to eq(CGI.unescape(file_path)) expect(json_response['content']).to eq(put_params[:content]) diff --git a/spec/requests/api/group_variables_spec.rb b/spec/requests/api/group_variables_spec.rb index 93b9cf85c1d..a4f198eb5c9 100644 --- a/spec/requests/api/group_variables_spec.rb +++ b/spec/requests/api/group_variables_spec.rb @@ -15,7 +15,7 @@ describe API::GroupVariables do it 'returns group variables' do get api("/groups/#{group.id}/variables", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a(Array) end end @@ -24,7 +24,7 @@ describe API::GroupVariables do it 'does not return group variables' do get api("/groups/#{group.id}/variables", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -32,7 +32,7 @@ describe API::GroupVariables do it 'does not return group variables' do get api("/groups/#{group.id}/variables") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -48,7 +48,7 @@ describe API::GroupVariables do it 'returns group variable details' do get api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['value']).to eq(variable.value) expect(json_response['protected']).to eq(variable.protected?) end @@ -56,7 +56,7 @@ describe API::GroupVariables do it 'responds with 404 Not Found if requesting non-existing variable' do get api("/groups/#{group.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -64,7 +64,7 @@ describe API::GroupVariables do it 'does not return group variable details' do get api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -72,7 +72,7 @@ describe API::GroupVariables do it 'does not return group variable details' do get api("/groups/#{group.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -90,7 +90,7 @@ describe API::GroupVariables do post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true end.to change {group.variables.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_truthy @@ -101,7 +101,7 @@ describe API::GroupVariables do post api("/groups/#{group.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' end.to change {group.variables.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_falsey @@ -112,7 +112,7 @@ describe API::GroupVariables do post api("/groups/#{group.id}/variables", user), key: variable.key, value: 'VALUE_2' end.to change {group.variables.count}.by(0) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -120,7 +120,7 @@ describe API::GroupVariables do it 'does not create variable' do post api("/groups/#{group.id}/variables", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -128,7 +128,7 @@ describe API::GroupVariables do it 'does not create variable' do post api("/groups/#{group.id}/variables") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -149,7 +149,7 @@ describe API::GroupVariables do updated_variable = group.variables.first - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(value_before).to eq(variable.value) expect(updated_variable.value).to eq('VALUE_1_UP') expect(updated_variable).to be_protected @@ -158,7 +158,7 @@ describe API::GroupVariables do it 'responds with 404 Not Found if requesting non-existing variable' do put api("/groups/#{group.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -166,7 +166,7 @@ describe API::GroupVariables do it 'does not update variable' do put api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -174,7 +174,7 @@ describe API::GroupVariables do it 'does not update variable' do put api("/groups/#{group.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -191,14 +191,14 @@ describe API::GroupVariables do expect do delete api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change {group.variables.count}.by(-1) end it 'responds with 404 Not Found if requesting non-existing variable' do delete api("/groups/#{group.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -210,7 +210,7 @@ describe API::GroupVariables do it 'does not delete variable' do delete api("/groups/#{group.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -218,7 +218,7 @@ describe API::GroupVariables do it 'does not delete variable' do delete api("/groups/#{group.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 1671a046fdf..8ce9fcc80bf 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -23,7 +23,7 @@ describe API::Groups do it "returns public groups" do get api("/groups") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -36,7 +36,7 @@ describe API::Groups do it "normal user: returns an array of groups of user1" do get api("/groups", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -47,7 +47,7 @@ describe API::Groups do it "does not include statistics" do get api("/groups", user1), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first).not_to include 'statistics' @@ -58,7 +58,7 @@ describe API::Groups do it "admin: returns an array of all groups" do get api("/groups", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(2) @@ -67,7 +67,7 @@ describe API::Groups do it "does not include statistics by default" do get api("/groups", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first).not_to include('statistics') @@ -87,7 +87,7 @@ describe API::Groups do get api("/groups", admin), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response) @@ -99,7 +99,7 @@ describe API::Groups do it "returns all groups excluding skipped groups" do get api("/groups", admin), skip_groups: [group2.id] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -114,7 +114,7 @@ describe API::Groups do get api("/groups", user1), all_available: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(response_groups).to contain_exactly(public_group.name, group1.name) @@ -132,7 +132,7 @@ describe API::Groups do it "sorts by name ascending by default" do get api("/groups", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(response_groups).to eq([group3.name, group1.name]) @@ -141,7 +141,7 @@ describe API::Groups do it "sorts in descending order when passed" do get api("/groups", user1), sort: "desc" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(response_groups).to eq([group1.name, group3.name]) @@ -150,7 +150,7 @@ describe API::Groups do it "sorts by the order_by param" do get api("/groups", user1), order_by: "path" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(response_groups).to eq([group1.name, group3.name]) @@ -163,7 +163,7 @@ describe API::Groups do get api('/groups', user2), owned: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -176,12 +176,12 @@ describe API::Groups do context 'when unauthenticated' do it 'returns 404 for a private group' do get api("/groups/#{group2.id}") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 200 for a public group' do get api("/groups/#{group1.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -192,7 +192,7 @@ describe API::Groups do get api("/groups/#{group1.id}", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(group1.id) expect(json_response['name']).to eq(group1.name) expect(json_response['path']).to eq(group1.path) @@ -214,13 +214,13 @@ describe API::Groups do it "does not return a non existing group" do get api("/groups/1328", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not return a group not attached to user1" do get api("/groups/#{group2.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -228,14 +228,14 @@ describe API::Groups do it "returns any existing group" do get api("/groups/#{group2.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(group2.name) end it "does not return a non existing group" do get api("/groups/1328", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -243,20 +243,20 @@ describe API::Groups do it 'returns any existing group' do get api("/groups/#{group1.path}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(group1.name) end it 'does not return a non existing group' do get api('/groups/unknown', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not return a group not attached to user1' do get api("/groups/#{group2.path}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -268,7 +268,7 @@ describe API::Groups do it 'updates the group' do put api("/groups/#{group1.id}", user1), name: new_group_name, request_access_enabled: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) expect(json_response['request_access_enabled']).to eq(true) end @@ -276,7 +276,7 @@ describe API::Groups do it 'returns 404 for a non existing group' do put api('/groups/1328', user1), name: new_group_name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -284,7 +284,7 @@ describe API::Groups do it 'updates the group' do put api("/groups/#{group1.id}", admin), name: new_group_name - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) end end @@ -293,7 +293,7 @@ describe API::Groups do it 'does not updates the group' do put api("/groups/#{group1.id}", user2), name: new_group_name - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -301,7 +301,7 @@ describe API::Groups do it 'returns 404 when trying to update the group' do put api("/groups/#{group2.id}", user1), name: new_group_name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -311,7 +311,7 @@ describe API::Groups do it "returns the group's projects" do get api("/groups/#{group1.id}/projects", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(2) project_names = json_response.map { |proj| proj['name'] } @@ -322,7 +322,7 @@ describe API::Groups do it "returns the group's projects with simple representation" do get api("/groups/#{group1.id}/projects", user1), simple: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(2) project_names = json_response.map { |proj| proj['name'] } @@ -335,7 +335,7 @@ describe API::Groups do get api("/groups/#{group1.id}/projects", user1), visibility: 'public' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an(Array) expect(json_response.length).to eq(1) @@ -345,13 +345,13 @@ describe API::Groups do it "does not return a non existing group" do get api("/groups/1328/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not return a group not attached to user1" do get api("/groups/#{group2.id}/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "only returns projects to which user has access" do @@ -359,7 +359,7 @@ describe API::Groups do get api("/groups/#{group1.id}/projects", user3) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project3.name) @@ -370,7 +370,7 @@ describe API::Groups do get api("/groups/#{project2.group.id}/projects", user3), owned: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project2.name) end @@ -380,7 +380,7 @@ describe API::Groups do get api("/groups/#{group1.id}/projects", user1), starred: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project1.name) end @@ -390,7 +390,7 @@ describe API::Groups do it "returns any existing group" do get api("/groups/#{group2.id}/projects", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project2.name) @@ -399,7 +399,7 @@ describe API::Groups do it "does not return a non existing group" do get api("/groups/1328/projects", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -407,7 +407,7 @@ describe API::Groups do it 'returns any existing group' do get api("/groups/#{group1.path}/projects", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers project_names = json_response.map { |proj| proj['name'] } expect(project_names).to match_array([project1.name, project3.name]) @@ -416,13 +416,13 @@ describe API::Groups do it 'does not return a non existing group' do get api('/groups/unknown/projects', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not return a group not attached to user1' do get api("/groups/#{group2.path}/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -432,7 +432,7 @@ describe API::Groups do it "does not create group" do post api("/groups", user1), attributes_for(:group) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'as owner', :nested_groups do @@ -443,7 +443,7 @@ describe API::Groups do it 'can create subgroups' do post api("/groups", user1), parent_id: group2.id, name: 'foo', path: 'foo' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -455,7 +455,7 @@ describe API::Groups do it 'cannot create subgroups' do post api("/groups", user1), parent_id: group2.id, name: 'foo', path: 'foo' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -466,7 +466,7 @@ describe API::Groups do post api("/groups", user3), group - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(group[:name]) expect(json_response["path"]).to eq(group[:path]) @@ -481,7 +481,7 @@ describe API::Groups do post api("/groups", user3), group - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["full_path"]).to eq("#{parent.path}/#{group[:path]}") expect(json_response["parent_id"]).to eq(parent.id) @@ -490,20 +490,20 @@ describe API::Groups do it "does not create group, duplicate" do post api("/groups", user3), { name: 'Duplicate Test', path: group2.path } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(response.message).to eq("Bad Request") end it "returns 400 bad request error if name not given" do post api("/groups", user3), { path: group2.path } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 bad request error if path not given" do post api("/groups", user3), { name: 'test' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -513,7 +513,7 @@ describe API::Groups do it "removes group" do delete api("/groups/#{group1.id}", user1) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it_behaves_like '412 response' do @@ -526,19 +526,19 @@ describe API::Groups do delete api("/groups/#{group1.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "does not remove a non existing group" do delete api("/groups/1328", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not remove a group not attached to user1" do delete api("/groups/#{group2.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -546,13 +546,13 @@ describe API::Groups do it "removes any existing group" do delete api("/groups/#{group2.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it "does not remove a non existing group" do delete api("/groups/1328", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -570,7 +570,7 @@ describe API::Groups do it "does not transfer project to group" do post api("/groups/#{group1.id}/projects/#{project.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -578,7 +578,7 @@ describe API::Groups do it "transfers project to group" do post api("/groups/#{group1.id}/projects/#{project.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when using project path in URL' do @@ -586,7 +586,7 @@ describe API::Groups do it "transfers project to group" do post api("/groups/#{group1.id}/projects/#{project_path}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -594,7 +594,7 @@ describe API::Groups do it "does not transfer project to group" do post api("/groups/#{group1.id}/projects/nogroup%2Fnoproject", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -604,7 +604,7 @@ describe API::Groups do it "transfers project to group" do post api("/groups/#{group1.path}/projects/#{project_path}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -612,7 +612,7 @@ describe API::Groups do it "does not transfer project to group" do post api("/groups/noexist/projects/#{project_path}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb index 1274e66bb4c..d919899282d 100644 --- a/spec/requests/api/internal_spec.rb +++ b/spec/requests/api/internal_spec.rb @@ -14,7 +14,7 @@ describe API::Internal do get api("/internal/check"), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['api_version']).to eq(API::API.version) expect(json_response['redis']).to be(true) end @@ -35,7 +35,7 @@ describe API::Internal do it 'returns one broadcast message' do get api('/internal/broadcast_message'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['message']).to eq(broadcast_message.message) end end @@ -44,7 +44,7 @@ describe API::Internal do it 'returns nothing' do get api('/internal/broadcast_message'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -55,7 +55,7 @@ describe API::Internal do get api('/internal/broadcast_message'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -68,7 +68,7 @@ describe API::Internal do it 'returns active broadcast message(s)' do get api('/internal/broadcast_messages'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response[0]['message']).to eq(broadcast_message.message) end end @@ -77,7 +77,7 @@ describe API::Internal do it 'returns nothing' do get api('/internal/broadcast_messages'), secret_token: secret_token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -154,7 +154,7 @@ describe API::Internal do it 'returns the correct information about the key' do lfs_auth(key.id, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['username']).to eq(user.username) expect(json_response['lfs_token']).to eq(Gitlab::LfsToken.new(key).token) @@ -164,7 +164,7 @@ describe API::Internal do it 'returns a 404 when the wrong key is provided' do lfs_auth(nil, project) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -174,7 +174,7 @@ describe API::Internal do it 'returns the correct information about the key' do lfs_auth(key.id, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['username']).to eq("lfs+deploy-key-#{key.id}") expect(json_response['lfs_token']).to eq(Gitlab::LfsToken.new(key).token) expect(json_response['repository_http_path']).to eq(project.http_url_to_repo) @@ -186,7 +186,7 @@ describe API::Internal do it do get(api("/internal/discover"), key_id: key.id, secret_token: secret_token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(user.name) end @@ -214,7 +214,7 @@ describe API::Internal do GIT_ALTERNATE_OBJECT_DIRECTORIES: 'bar' }.to_json) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -222,7 +222,7 @@ describe API::Internal do it 'responds with success' do push(key, project.wiki) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.wiki.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("wiki-#{project.id}") @@ -234,7 +234,7 @@ describe API::Internal do it 'responds with success' do pull(key, project.wiki) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.wiki.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("wiki-#{project.id}") @@ -248,7 +248,7 @@ describe API::Internal do allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:ssh_upload_pack).and_return(false) pull(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -262,7 +262,7 @@ describe API::Internal do allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:ssh_upload_pack).and_return(true) pull(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -283,7 +283,7 @@ describe API::Internal do allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:ssh_receive_pack).and_return(false) push(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -297,7 +297,7 @@ describe API::Internal do allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:ssh_receive_pack).and_return(true) push(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -315,7 +315,7 @@ describe API::Internal do it do pull(key, project_with_repo_path('/' + project.full_path)) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -326,7 +326,7 @@ describe API::Internal do it do pull(key, project_with_repo_path(project.full_path)) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy expect(json_response["repository_path"]).to eq(project.repository.path_to_repo) expect(json_response["gl_repository"]).to eq("project-#{project.id}") @@ -344,7 +344,7 @@ describe API::Internal do it do pull(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey expect(user).not_to have_an_activity_record end @@ -354,7 +354,7 @@ describe API::Internal do it do push(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey expect(user).not_to have_an_activity_record end @@ -372,7 +372,7 @@ describe API::Internal do it do pull(key, personal_project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey expect(user).not_to have_an_activity_record end @@ -382,7 +382,7 @@ describe API::Internal do it do push(key, personal_project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey expect(user).not_to have_an_activity_record end @@ -399,7 +399,7 @@ describe API::Internal do it do pull(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy end end @@ -408,7 +408,7 @@ describe API::Internal do it do push(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey end end @@ -425,7 +425,7 @@ describe API::Internal do it do archive(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_truthy end end @@ -434,7 +434,7 @@ describe API::Internal do it do archive(key, project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey end end @@ -444,7 +444,7 @@ describe API::Internal do it do pull(key, project_with_repo_path('gitlab/notexist')) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey end end @@ -453,7 +453,7 @@ describe API::Internal do it do pull(OpenStruct.new(id: 0), project) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["status"]).to be_falsey end end @@ -535,7 +535,7 @@ describe API::Internal do it 'rejects the push' do push_with_path(key, old_path_to_repo) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq(project_moved_message) end @@ -543,7 +543,7 @@ describe API::Internal do it 'rejects the SSH pull' do pull_with_path(key, old_path_to_repo) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to be_falsey expect(json_response['message']).to eq(project_moved_message) end @@ -614,7 +614,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_http_status(200) + # expect(response).to have_gitlab_http_status(200) # end # # it "calls the Gitaly client with the wiki's repository if it's a wiki" do @@ -626,7 +626,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_wiki_params # - # expect(response).to have_http_status(200) + # expect(response).to have_gitlab_http_status(200) # end # # it "returns 500 if the gitaly call fails" do @@ -635,7 +635,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_http_status(500) + # expect(response).to have_gitlab_http_status(500) # end # # context 'with a gl_repository parameter' do @@ -656,7 +656,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_params # - # expect(response).to have_http_status(200) + # expect(response).to have_gitlab_http_status(200) # end # # it "calls the Gitaly client with the wiki's repository if it's a wiki" do @@ -668,7 +668,7 @@ describe API::Internal do # # post api("/internal/notify_post_receive"), valid_wiki_params # - # expect(response).to have_http_status(200) + # expect(response).to have_gitlab_http_status(200) # end # end # end @@ -734,7 +734,7 @@ describe API::Internal do it 'returns one broadcast message' do post api("/internal/post_receive"), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(broadcast_message.message) end end @@ -743,7 +743,7 @@ describe API::Internal do it 'returns empty string' do post api("/internal/post_receive"), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(nil) end end @@ -754,7 +754,7 @@ describe API::Internal do post api("/internal/post_receive"), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['broadcast_message']).to eq(nil) end end diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 972e57bc373..99525cd0a6a 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -67,7 +67,7 @@ describe API::Issues, :mailer do it "returns authentication error" do get api("/issues") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context "when authenticated" do @@ -297,7 +297,7 @@ describe API::Issues, :mailer do it 'matches V4 response schema' do get api('/issues', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/issues') end end @@ -474,7 +474,7 @@ describe API::Issues, :mailer do it 'returns an array of issues with no milestone' do get api("#{base_url}?milestone=#{no_milestone_title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect_paginated_array_response(size: 1) expect(json_response.first['id']).to eq(group_confidential_issue.id) @@ -535,7 +535,7 @@ describe API::Issues, :mailer do it 'returns 404 when project does not exist' do get api('/projects/1000/issues', non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 on private projects for other users" do @@ -544,7 +544,7 @@ describe API::Issues, :mailer do get api("/projects/#{private_project.id}/issues", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns no issues when user has access to project but not issues' do @@ -732,7 +732,7 @@ describe API::Issues, :mailer do it 'exposes known attributes' do get api("/projects/#{project.id}/issues/#{issue.iid}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(issue.id) expect(json_response['iid']).to eq(issue.iid) expect(json_response['project_id']).to eq(issue.project.id) @@ -753,7 +753,7 @@ describe API::Issues, :mailer do it "exposes the 'closed_at' attribute" do get api("/projects/#{project.id}/issues/#{closed_issue.iid}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['closed_at']).to be_present end @@ -773,39 +773,39 @@ describe API::Issues, :mailer do it "returns a project issue by internal id" do get api("/projects/#{project.id}/issues/#{issue.iid}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(issue.title) expect(json_response['iid']).to eq(issue.iid) end it "returns 404 if issue id not found" do get api("/projects/#{project.id}/issues/54321", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 if the issue ID is used" do get api("/projects/#{project.id}/issues/#{issue.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'confidential issues' do it "returns 404 for non project members" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 for project members with guest role" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns confidential issue for project members" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -813,7 +813,7 @@ describe API::Issues, :mailer do it "returns confidential issue for author" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -821,7 +821,7 @@ describe API::Issues, :mailer do it "returns confidential issue for assignee" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", assignee) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -829,7 +829,7 @@ describe API::Issues, :mailer do it "returns confidential issue for admin" do get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -842,7 +842,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', assignee_id: user2.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['assignee']['name']).to eq(user2.name) expect(json_response['assignees'].first['name']).to eq(user2.name) @@ -854,7 +854,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', assignee_ids: [user2.id, guest.id] - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['assignees'].count).to eq(1) end @@ -865,7 +865,7 @@ describe API::Issues, :mailer do title: 'new issue', labels: 'label, label2', weight: 3, assignee_ids: [user2.id] - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['description']).to be_nil expect(json_response['labels']).to eq(%w(label label2)) @@ -878,7 +878,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: true - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_truthy end @@ -887,7 +887,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: 'y' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_truthy end @@ -896,7 +896,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: false - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_falsy end @@ -905,7 +905,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end @@ -923,7 +923,7 @@ describe API::Issues, :mailer do it "returns a 400 bad request if title not given" do post api("/projects/#{project.id}/issues", user), labels: 'label, label2' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'allows special label names' do @@ -941,7 +941,7 @@ describe API::Issues, :mailer do it 'returns 400 if title is too long' do post api("/projects/#{project.id}/issues", user), title: 'g' * 256 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' ]) @@ -985,7 +985,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', due_date: due_date - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['description']).to be_nil expect(json_response['due_date']).to eq(due_date) @@ -998,7 +998,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues", user), title: 'new issue', labels: 'label, label2', created_at: creation_time - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) end end @@ -1028,7 +1028,7 @@ describe API::Issues, :mailer do it "does not create a new project issue" do expect { post api("/projects/#{project.id}/issues", user), params }.not_to change(Issue, :count) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) spam_logs = SpamLog.all @@ -1044,7 +1044,7 @@ describe API::Issues, :mailer do it "updates a project issue" do put api("/projects/#{project.id}/issues/#{issue.iid}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -1052,13 +1052,13 @@ describe API::Issues, :mailer do it "returns 404 error if issue iid not found" do put api("/projects/#{project.id}/issues/44444", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 error if issue id is used instead of the iid" do put api("/projects/#{project.id}/issues/#{issue.id}", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'allows special label names' do @@ -1078,33 +1078,33 @@ describe API::Issues, :mailer do it "returns 403 for non project members" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member), title: 'updated title' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 403 for project members with guest role" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest), title: 'updated title' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "updates a confidential issue for project members" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end it "updates a confidential issue for author" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end it "updates a confidential issue for admin" do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -1112,7 +1112,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), confidential: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_truthy end @@ -1120,7 +1120,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), confidential: false - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_falsy end @@ -1128,7 +1128,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user), confidential: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end end @@ -1149,7 +1149,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) spam_logs = SpamLog.all @@ -1167,7 +1167,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_id: 0 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignee']).to be_nil end @@ -1176,7 +1176,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_id: user2.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignee']['name']).to eq(user2.name) end @@ -1186,7 +1186,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_ids: [0] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignees']).to be_empty end @@ -1195,7 +1195,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_ids: [user2.id] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignees'].first['name']).to eq(user2.name) end @@ -1205,7 +1205,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), assignee_ids: [user2.id, guest.id] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignees'].size).to eq(1) end @@ -1219,7 +1219,7 @@ describe API::Issues, :mailer do it 'does not update labels if not present' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([label.title]) end @@ -1238,14 +1238,14 @@ describe API::Issues, :mailer do it 'removes all labels' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: '' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([]) end it 'updates labels' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: 'foo,bar' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'foo' expect(json_response['labels']).to include 'bar' end @@ -1267,7 +1267,7 @@ describe API::Issues, :mailer do it 'returns 400 if title is too long' do put api("/projects/#{project.id}/issues/#{issue.iid}", user), title: 'g' * 256 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' ]) @@ -1278,7 +1278,7 @@ describe API::Issues, :mailer do it "updates a project issue" do put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: 'label2', state_event: "close" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label2' expect(json_response['state']).to eq "closed" @@ -1287,7 +1287,7 @@ describe API::Issues, :mailer do it 'reopens a project isssue' do put api("/projects/#{project.id}/issues/#{closed_issue.iid}", user), state_event: 'reopen' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq 'opened' end @@ -1297,7 +1297,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), labels: 'label3', state_event: 'close', updated_at: update_time - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label3' expect(Time.parse(json_response['updated_at'])).to be_like_time(update_time) end @@ -1310,7 +1310,7 @@ describe API::Issues, :mailer do put api("/projects/#{project.id}/issues/#{issue.iid}", user), due_date: due_date - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['due_date']).to eq(due_date) end end @@ -1318,12 +1318,12 @@ describe API::Issues, :mailer do describe "DELETE /projects/:id/issues/:issue_iid" do it "rejects a non member from deleting an issue" do delete api("/projects/#{project.id}/issues/#{issue.iid}", non_member) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "rejects a developer from deleting an issue" do delete api("/projects/#{project.id}/issues/#{issue.iid}", author) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context "when the user is project owner" do @@ -1333,7 +1333,7 @@ describe API::Issues, :mailer do it "deletes the issue if an admin requests it" do delete api("/projects/#{project.id}/issues/#{issue.iid}", owner) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it_behaves_like '412 response' do @@ -1345,14 +1345,14 @@ describe API::Issues, :mailer do it 'returns 404 when trying to move an issue' do delete api("/projects/#{project.id}/issues/123", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end it 'returns 404 when using the issue ID instead of IID' do delete api("/projects/#{project.id}/issues/#{issue.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1364,7 +1364,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project.id) end @@ -1373,7 +1373,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), to_project_id: project.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue to project it originates from!') end end @@ -1383,7 +1383,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), to_project_id: target_project2.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!') end end @@ -1392,7 +1392,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", admin), to_project_id: target_project2.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project2.id) end @@ -1401,7 +1401,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Issue Not Found') end end @@ -1411,7 +1411,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/123/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Issue Not Found') end end @@ -1421,7 +1421,7 @@ describe API::Issues, :mailer do post api("/projects/123/issues/#{issue.iid}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end end @@ -1431,7 +1431,7 @@ describe API::Issues, :mailer do post api("/projects/#{project.id}/issues/#{issue.iid}/move", user), to_project_id: 123 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1440,32 +1440,32 @@ describe API::Issues, :mailer do it 'subscribes to an issue' do post api("/projects/#{project.id}/issues/#{issue.iid}/subscribe", user2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['subscribed']).to eq(true) end it 'returns 304 if already subscribed' do post api("/projects/#{project.id}/issues/#{issue.iid}/subscribe", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the issue is not found' do post api("/projects/#{project.id}/issues/123/subscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue ID is used instead of the iid' do post api("/projects/#{project.id}/issues/#{issue.id}/subscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue is confidential' do post api("/projects/#{project.id}/issues/#{confidential_issue.iid}/subscribe", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1473,32 +1473,32 @@ describe API::Issues, :mailer do it 'unsubscribes from an issue' do post api("/projects/#{project.id}/issues/#{issue.iid}/unsubscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['subscribed']).to eq(false) end it 'returns 304 if not subscribed' do post api("/projects/#{project.id}/issues/#{issue.iid}/unsubscribe", user2) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the issue is not found' do post api("/projects/#{project.id}/issues/123/unsubscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if using the issue ID instead of iid' do post api("/projects/#{project.id}/issues/#{issue.id}/unsubscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue is confidential' do post api("/projects/#{project.id}/issues/#{confidential_issue.iid}/unsubscribe", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1539,7 +1539,7 @@ describe API::Issues, :mailer do it "returns 404 when issue doesn't exists" do get api("/projects/#{project.id}/issues/9999/closed_by", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1549,7 +1549,7 @@ describe API::Issues, :mailer do it 'exposes known attributes' do get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) @@ -1558,12 +1558,12 @@ describe API::Issues, :mailer do it "returns unautorized for non-admin users" do get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end def expect_paginated_array_response(size: nil) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(size) if size diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb index 2d7cc1a1798..3b7b9c889e7 100644 --- a/spec/requests/api/jobs_spec.rb +++ b/spec/requests/api/jobs_spec.rb @@ -31,7 +31,7 @@ describe API::Jobs do context 'authorized user' do it 'returns project jobs' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array end @@ -55,7 +55,7 @@ describe API::Jobs do let(:query) { { 'scope' => 'pending' } } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -64,7 +64,7 @@ describe API::Jobs do let(:query) { { scope: %w(pending running) } } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -72,7 +72,7 @@ describe API::Jobs do context 'respond 400 when scope contains invalid state' do let(:query) { { scope: %w(unknown running) } } - it { expect(response).to have_http_status(400) } + it { expect(response).to have_gitlab_http_status(400) } end end @@ -80,7 +80,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not return project jobs' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -94,7 +94,7 @@ describe API::Jobs do context 'authorized user' do it 'returns pipeline jobs' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array end @@ -118,7 +118,7 @@ describe API::Jobs do let(:query) { { 'scope' => 'pending' } } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -127,7 +127,7 @@ describe API::Jobs do let(:query) { { scope: %w(pending running) } } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -135,7 +135,7 @@ describe API::Jobs do context 'respond 400 when scope contains invalid state' do let(:query) { { scope: %w(unknown running) } } - it { expect(response).to have_http_status(400) } + it { expect(response).to have_gitlab_http_status(400) } end context 'jobs in different pipelines' do @@ -152,7 +152,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not return jobs' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -164,7 +164,7 @@ describe API::Jobs do context 'authorized user' do it 'returns specific job data' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('test') end @@ -183,7 +183,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not return specific job data' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -207,7 +207,7 @@ describe API::Jobs do get_artifact_file(artifact) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -219,7 +219,7 @@ describe API::Jobs do get_artifact_file(artifact) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -231,7 +231,7 @@ describe API::Jobs do get_artifact_file(artifact) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -244,7 +244,7 @@ describe API::Jobs do get_artifact_file(artifact) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers) .to include('Content-Type' => 'application/json', 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/) @@ -256,7 +256,7 @@ describe API::Jobs do it 'does not return job artifact file' do get_artifact_file('some/artifact') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -281,7 +281,7 @@ describe API::Jobs do end it 'returns specific job artifacts' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers).to include(download_headers) expect(response.body).to match_file(job.artifacts_file.file.file) end @@ -292,13 +292,13 @@ describe API::Jobs do it 'hides artifacts and rejects request' do expect(project).to be_private - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end it 'does not return job artifacts if not uploaded' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -323,7 +323,7 @@ describe API::Jobs do it 'does not find a resource in a private project' do expect(project).to be_private - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -335,13 +335,13 @@ describe API::Jobs do end it 'gives 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'non-existing job' do shared_examples 'not found' do - it { expect(response).to have_http_status(:not_found) } + it { expect(response).to have_gitlab_http_status(:not_found) } end context 'has no such ref' do @@ -369,7 +369,7 @@ describe API::Jobs do "attachment; filename=#{job.artifacts_file.filename}" } end - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } it { expect(response.headers).to include(download_headers) } end @@ -410,7 +410,7 @@ describe API::Jobs do context 'authorized user' do it 'returns specific job trace' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).to eq(job.trace.raw) end end @@ -419,7 +419,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not return specific job trace' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -432,7 +432,7 @@ describe API::Jobs do context 'authorized user' do context 'user with :update_build persmission' do it 'cancels running or pending job' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(project.builds.first.status).to eq('canceled') end end @@ -441,7 +441,7 @@ describe API::Jobs do let(:api_user) { reporter } it 'does not cancel job' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -450,7 +450,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not cancel job' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -465,7 +465,7 @@ describe API::Jobs do context 'authorized user' do context 'user with :update_build permission' do it 'retries non-running job' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(project.builds.first.status).to eq('canceled') expect(json_response['status']).to eq('pending') end @@ -475,7 +475,7 @@ describe API::Jobs do let(:api_user) { reporter } it 'does not retry job' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -484,7 +484,7 @@ describe API::Jobs do let(:api_user) { nil } it 'does not retry job' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -498,7 +498,7 @@ describe API::Jobs do let(:job) { create(:ci_build, :trace, :artifacts, :success, project: project, pipeline: pipeline) } it 'erases job content' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job).not_to have_trace expect(job.artifacts_file.exists?).to be_falsy expect(job.artifacts_metadata.exists?).to be_falsy @@ -516,7 +516,7 @@ describe API::Jobs do let(:job) { create(:ci_build, :trace, project: project, pipeline: pipeline) } it 'responds with forbidden' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -533,7 +533,7 @@ describe API::Jobs do end it 'keeps artifacts' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(job.reload.artifacts_expire_at).to be_nil end end @@ -542,7 +542,7 @@ describe API::Jobs do let(:job) { create(:ci_build, project: project, pipeline: pipeline) } it 'responds with not found' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -557,7 +557,7 @@ describe API::Jobs do context 'when user is authorized to trigger a manual action' do it 'plays the job' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['user']['id']).to eq(user.id) expect(json_response['id']).to eq(job.id) expect(job.reload).to be_pending @@ -570,7 +570,7 @@ describe API::Jobs do it 'does not trigger a manual action' do expect(job.reload).to be_manual - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -579,7 +579,7 @@ describe API::Jobs do it 'does not trigger a manual action' do expect(job.reload).to be_manual - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -587,7 +587,7 @@ describe API::Jobs do context 'on a non-playable job' do it 'returns a status code 400, Bad Request' do - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 expect(response.body).to match("Unplayable Job") end end diff --git a/spec/requests/api/keys_spec.rb b/spec/requests/api/keys_spec.rb index f534332ca6c..3c4719964b6 100644 --- a/spec/requests/api/keys_spec.rb +++ b/spec/requests/api/keys_spec.rb @@ -10,14 +10,14 @@ describe API::Keys do context 'when unauthenticated' do it 'returns authentication error' do get api("/keys/#{key.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing key' do get api('/keys/999999', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end @@ -25,7 +25,7 @@ describe API::Keys do user.keys << key user.save get api("/keys/#{key.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(key.title) expect(json_response['user']['id']).to eq(user.id) expect(json_response['user']['username']).to eq(user.username) diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb index b231fdea2a3..3498e5bc8d9 100644 --- a/spec/requests/api/labels_spec.rb +++ b/spec/requests/api/labels_spec.rb @@ -27,7 +27,7 @@ describe API::Labels do get api("/projects/#{project.id}/labels", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(3) @@ -75,7 +75,7 @@ describe API::Labels do description: 'test', priority: 2 - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('Foo') expect(json_response['color']).to eq('#FFAABB') expect(json_response['description']).to eq('test') @@ -109,19 +109,19 @@ describe API::Labels do it 'returns a 400 bad request if name not given' do post api("/projects/#{project.id}/labels", user), color: '#FFAABB' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 bad request if color not given' do post api("/projects/#{project.id}/labels", user), name: 'Foobar' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 for invalid color' do post api("/projects/#{project.id}/labels", user), name: 'Foo', color: '#FFAA' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end @@ -129,7 +129,7 @@ describe API::Labels do post api("/projects/#{project.id}/labels", user), name: 'Foo', color: '#FFAAFFFF' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end @@ -137,7 +137,7 @@ describe API::Labels do post api("/projects/#{project.id}/labels", user), name: ',', color: '#FFAABB' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq(['is invalid']) end @@ -150,7 +150,7 @@ describe API::Labels do name: group_label.name, color: '#FFAABB' - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Label already exists') end @@ -160,14 +160,14 @@ describe API::Labels do color: '#FFAAFFFF', priority: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 409 if label already exists in project' do post api("/projects/#{project.id}/labels", user), name: 'label1', color: '#FFAABB' - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Label already exists') end end @@ -176,18 +176,18 @@ describe API::Labels do it 'returns 204 for existing label' do delete api("/projects/#{project.id}/labels", user), name: 'label1' - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'returns 404 for non existing label' do delete api("/projects/#{project.id}/labels", user), name: 'label2' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Label Not Found') end it 'returns 400 for wrong parameters' do delete api("/projects/#{project.id}/labels", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it_behaves_like '412 response' do @@ -203,7 +203,7 @@ describe API::Labels do new_name: 'New Label', color: '#FFFFFF', description: 'test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('New Label') expect(json_response['color']).to eq('#FFFFFF') expect(json_response['description']).to eq('test') @@ -213,7 +213,7 @@ describe API::Labels do put api("/projects/#{project.id}/labels", user), name: 'label1', new_name: 'New Label' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('New Label') expect(json_response['color']).to eq(label1.color) end @@ -222,7 +222,7 @@ describe API::Labels do put api("/projects/#{project.id}/labels", user), name: 'label1', color: '#FFFFFF' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(label1.name) expect(json_response['color']).to eq('#FFFFFF') end @@ -232,7 +232,7 @@ describe API::Labels do name: 'bug', description: 'test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(priority_label.name) expect(json_response['description']).to eq('test') expect(json_response['priority']).to eq(3) @@ -272,18 +272,18 @@ describe API::Labels do put api("/projects/#{project.id}/labels", user), name: 'label2', new_name: 'label3' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 400 if no label name given' do put api("/projects/#{project.id}/labels", user), new_name: 'label2' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end it 'returns 400 if no new parameters given' do put api("/projects/#{project.id}/labels", user), name: 'label1' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('new_name, color, description, priority are missing, '\ 'at least one parameter must be provided') end @@ -293,7 +293,7 @@ describe API::Labels do name: 'label1', new_name: ',', color: '#FFFFFF' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq(['is invalid']) end @@ -301,7 +301,7 @@ describe API::Labels do put api("/projects/#{project.id}/labels", user), name: 'label1', color: '#FF' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end @@ -309,7 +309,7 @@ describe API::Labels do post api("/projects/#{project.id}/labels", user), name: 'Foo', color: '#FFAAFFFF' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['color']).to eq(['must be a valid color code']) end @@ -318,7 +318,7 @@ describe API::Labels do name: 'Foo', priority: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -327,7 +327,7 @@ describe API::Labels do it "subscribes to the label" do post api("/projects/#{project.id}/labels/#{label1.title}/subscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_truthy end @@ -337,7 +337,7 @@ describe API::Labels do it "subscribes to the label" do post api("/projects/#{project.id}/labels/#{label1.id}/subscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_truthy end @@ -351,7 +351,7 @@ describe API::Labels do it "returns 304" do post api("/projects/#{project.id}/labels/#{label1.id}/subscribe", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end @@ -359,7 +359,7 @@ describe API::Labels do it "returns 404 error" do post api("/projects/#{project.id}/labels/1234/subscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -373,7 +373,7 @@ describe API::Labels do it "unsubscribes from the label" do post api("/projects/#{project.id}/labels/#{label1.title}/unsubscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_falsey end @@ -383,7 +383,7 @@ describe API::Labels do it "unsubscribes from the label" do post api("/projects/#{project.id}/labels/#{label1.id}/unsubscribe", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_falsey end @@ -397,7 +397,7 @@ describe API::Labels do it "returns 304" do post api("/projects/#{project.id}/labels/#{label1.id}/unsubscribe", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end @@ -405,7 +405,7 @@ describe API::Labels do it "returns 404 error" do post api("/projects/#{project.id}/labels/1234/unsubscribe", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb index df7c91b5bc1..e3065840e6f 100644 --- a/spec/requests/api/lint_spec.rb +++ b/spec/requests/api/lint_spec.rb @@ -10,7 +10,7 @@ describe API::Lint do it 'passes validation' do post api('/ci/lint'), { content: yaml_content } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Hash expect(json_response['status']).to eq('valid') expect(json_response['errors']).to eq([]) @@ -21,7 +21,7 @@ describe API::Lint do it 'responds with errors about invalid syntax' do post api('/ci/lint'), { content: 'invalid content' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('invalid') expect(json_response['errors']).to eq(['Invalid configuration format']) end @@ -29,7 +29,7 @@ describe API::Lint do it "responds with errors about invalid configuration" do post api('/ci/lint'), { content: '{ image: "ruby:2.1", services: ["postgres"] }' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('invalid') expect(json_response['errors']).to eq(['jobs config should contain at least one visible job']) end @@ -39,7 +39,7 @@ describe API::Lint do it 'responds with validation error about missing content' do post api('/ci/lint') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('content is missing') end end diff --git a/spec/requests/api/members_spec.rb b/spec/requests/api/members_spec.rb index d3bae8d2888..3349e396ab8 100644 --- a/spec/requests/api/members_spec.rb +++ b/spec/requests/api/members_spec.rb @@ -35,7 +35,7 @@ describe API::Members do get api("/#{source_type.pluralize}/#{source.id}/members", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(2) @@ -49,7 +49,7 @@ describe API::Members do get api("/#{source_type.pluralize}/#{source.id}/members", developer) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(2) @@ -59,7 +59,7 @@ describe API::Members do it 'finds members with query string' do get api("/#{source_type.pluralize}/#{source.id}/members", developer), query: master.username - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.count).to eq(1) @@ -81,7 +81,7 @@ describe API::Members do user = public_send(type) get api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # User attributes expect(json_response['id']).to eq(developer.id) expect(json_response['name']).to eq(developer.name) @@ -116,7 +116,7 @@ describe API::Members do post api("/#{source_type.pluralize}/#{source.id}/members", user), user_id: access_requester.id, access_level: Member::MASTER - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -129,7 +129,7 @@ describe API::Members do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: access_requester.id, access_level: Member::MASTER - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) expect(source.requesters.count).to eq(0) expect(json_response['id']).to eq(access_requester.id) @@ -142,7 +142,7 @@ describe API::Members do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id, access_level: Member::DEVELOPER, expires_at: '2016-08-05' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) expect(json_response['id']).to eq(stranger.id) expect(json_response['access_level']).to eq(Member::DEVELOPER) @@ -154,28 +154,28 @@ describe API::Members do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: master.id, access_level: Member::MASTER - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) end it 'returns 400 when user_id is not given' do post api("/#{source_type.pluralize}/#{source.id}/members", master), access_level: Member::MASTER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access_level is not given' do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access_level is not valid' do post api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id, access_level: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -197,7 +197,7 @@ describe API::Members do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user), access_level: Member::MASTER - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -208,7 +208,7 @@ describe API::Members do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master), access_level: Member::MASTER, expires_at: '2016-08-05' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(developer.id) expect(json_response['access_level']).to eq(Member::MASTER) expect(json_response['expires_at']).to eq('2016-08-05') @@ -219,20 +219,20 @@ describe API::Members do put api("/#{source_type.pluralize}/#{source.id}/members/123", master), access_level: Member::MASTER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 400 when access_level is not given' do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access level is not valid' do put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master), access_level: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -250,7 +250,7 @@ describe API::Members do user = public_send(type) delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -261,7 +261,7 @@ describe API::Members do expect do delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", developer) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { source.members.count }.by(-1) end end @@ -272,7 +272,7 @@ describe API::Members do expect do delete api("/#{source_type.pluralize}/#{source.id}/members/#{access_requester.id}", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end.not_to change { source.requesters.count } end end @@ -281,7 +281,7 @@ describe API::Members do expect do delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { source.members.count }.by(-1) end @@ -293,7 +293,7 @@ describe API::Members do it 'returns 404 if member does not exist' do delete api("/#{source_type.pluralize}/#{source.id}/members/123", master) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -344,7 +344,7 @@ describe API::Members do post api("/projects/#{project.id}/members", master), user_id: stranger.id, access_level: Member::OWNER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end.to change { project.members.count }.by(0) end end diff --git a/spec/requests/api/merge_request_diffs_spec.rb b/spec/requests/api/merge_request_diffs_spec.rb index d9da94d4713..bf4c8443b23 100644 --- a/spec/requests/api/merge_request_diffs_spec.rb +++ b/spec/requests/api/merge_request_diffs_spec.rb @@ -26,12 +26,12 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do it 'returns a 404 when merge_request id is used instead of the iid' do get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 when merge_request_iid not found' do get api("/projects/#{project.id}/merge_requests/999/versions", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -49,17 +49,17 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do it 'returns a 404 when merge_request id is used instead of the iid' do get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions/#{merge_request_diff.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 when merge_request version_id is not found' do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/versions/999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 when merge_request_iid is not found' do get api("/projects/#{project.id}/merge_requests/12345/versions/#{merge_request_diff.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb index 5e66e1607ba..28b1404a4f7 100644 --- a/spec/requests/api/merge_requests_spec.rb +++ b/spec/requests/api/merge_requests_spec.rb @@ -33,26 +33,26 @@ describe API::MergeRequests do it 'returns an array of all merge requests' do get api('/merge_requests', user), scope: 'all' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end it "returns authentication error without any scope" do get api("/merge_requests") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns authentication error when scope is assigned-to-me" do get api("/merge_requests"), scope: 'assigned-to-me' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns authentication error when scope is created-by-me" do get api("/merge_requests"), scope: 'created-by-me' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -158,7 +158,7 @@ describe API::MergeRequests do it 'returns merge requests for public projects' do get api("/projects/#{project.id}/merge_requests") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end @@ -166,7 +166,7 @@ describe API::MergeRequests do project = create(:project, :private) get api("/projects/#{project.id}/merge_requests") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb index 26cf653ca8e..e60716d46d7 100644 --- a/spec/requests/api/namespaces_spec.rb +++ b/spec/requests/api/namespaces_spec.rb @@ -10,7 +10,7 @@ describe API::Namespaces do context "when unauthenticated" do it "returns authentication error" do get api("/namespaces") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -21,7 +21,7 @@ describe API::Namespaces do group_kind_json_response = json_response.find { |resource| resource['kind'] == 'group' } user_kind_json_response = json_response.find { |resource| resource['kind'] == 'user' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(group_kind_json_response.keys).to contain_exactly('id', 'kind', 'name', 'path', 'full_path', 'parent_id', 'members_count_with_descendants') @@ -32,7 +32,7 @@ describe API::Namespaces do it "admin: returns an array of all namespaces" do get api("/namespaces", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(Namespace.count) @@ -41,7 +41,7 @@ describe API::Namespaces do it "admin: returns an array of matched namespaces" do get api("/namespaces?search=#{group2.name}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -75,7 +75,7 @@ describe API::Namespaces do it "user: returns an array of namespaces" do get api("/namespaces", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -84,7 +84,7 @@ describe API::Namespaces do it "admin: returns an array of matched namespaces" do get api("/namespaces?search=#{user.username}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb index fb440fa551c..784070db173 100644 --- a/spec/requests/api/notes_spec.rb +++ b/spec/requests/api/notes_spec.rb @@ -37,7 +37,7 @@ describe API::Notes do it "returns an array of issue notes" do get api("/projects/#{project.id}/issues/#{issue.iid}/notes", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(issue_note.note) @@ -46,14 +46,14 @@ describe API::Notes do it "returns a 404 error when issue id not found" do get api("/projects/#{project.id}/issues/12345/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "and current user cannot view the notes" do it "returns an empty array" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response).to be_empty @@ -67,7 +67,7 @@ describe API::Notes do it "returns 404" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -75,7 +75,7 @@ describe API::Notes do it "returns an empty array" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes", private_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(cross_reference_note.note) @@ -88,7 +88,7 @@ describe API::Notes do it "returns an array of snippet notes" do get api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(snippet_note.note) @@ -97,13 +97,13 @@ describe API::Notes do it "returns a 404 error when snippet id not found" do get api("/projects/#{project.id}/snippets/42/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 when not authorized" do get api("/projects/#{project.id}/snippets/#{snippet.id}/notes", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -111,7 +111,7 @@ describe API::Notes do it "returns an array of merge_requests notes" do get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(merge_request_note.note) @@ -120,13 +120,13 @@ describe API::Notes do it "returns a 404 error if merge request id not found" do get api("/projects/#{project.id}/merge_requests/4444/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 when not authorized" do get api("/projects/#{project.id}/merge_requests/4444/notes", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -136,21 +136,21 @@ describe API::Notes do it "returns an issue note by id" do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{issue_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(issue_note.note) end it "returns a 404 error if issue note not found" do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "and current user cannot view the note" do it "returns a 404 error" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes/#{cross_reference_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when issue is confidential" do @@ -161,7 +161,7 @@ describe API::Notes do it "returns 404" do get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{issue_note.id}", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -169,7 +169,7 @@ describe API::Notes do it "returns an issue note by id" do get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes/#{cross_reference_note.id}", private_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(cross_reference_note.note) end end @@ -180,14 +180,14 @@ describe API::Notes do it "returns a snippet note by id" do get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/#{snippet_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(snippet_note.note) end it "returns a 404 error if snippet note not found" do get api("/projects/#{project.id}/snippets/#{snippet.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -197,7 +197,7 @@ describe API::Notes do it "creates a new issue note" do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user), body: 'hi!' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -205,13 +205,13 @@ describe API::Notes do it "returns a 400 bad request error if body not given" do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if user not authenticated" do post api("/projects/#{project.id}/issues/#{issue.iid}/notes"), body: 'hi!' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end context 'when an admin or owner makes the request' do @@ -220,7 +220,7 @@ describe API::Notes do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user), body: 'hi!', created_at: creation_time - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) @@ -233,7 +233,7 @@ describe API::Notes do it 'creates a new issue note' do post api("/projects/#{project.id}/issues/#{issue2.iid}/notes", user), body: ':+1:' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq(':+1:') end end @@ -242,7 +242,7 @@ describe API::Notes do it 'creates a new issue note' do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user), body: ':+1:' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq(':+1:') end end @@ -252,7 +252,7 @@ describe API::Notes do it "creates a new snippet note" do post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user), body: 'hi!' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -260,13 +260,13 @@ describe API::Notes do it "returns a 400 bad request error if body not given" do post api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if user not authenticated" do post api("/projects/#{project.id}/snippets/#{snippet.id}/notes"), body: 'hi!' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -278,7 +278,7 @@ describe API::Notes do post api("/projects/#{project.id}/issues/#{issue.iid}/notes", user), body: 'Foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -314,7 +314,7 @@ describe API::Notes do it 'returns 200 status' do subject - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'creates a new note' do @@ -328,7 +328,7 @@ describe API::Notes do it 'returns 403 status' do subject - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not create a new note' do @@ -352,7 +352,7 @@ describe API::Notes do put api("/projects/#{project.id}/issues/#{issue.iid}/"\ "notes/#{issue_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -360,14 +360,14 @@ describe API::Notes do put api("/projects/#{project.id}/issues/#{issue.iid}/notes/12345", user), body: 'Hello!' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 400 bad request error if body not given' do put api("/projects/#{project.id}/issues/#{issue.iid}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -376,7 +376,7 @@ describe API::Notes do put api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -384,7 +384,7 @@ describe API::Notes do put api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/12345", user), body: "Hello!" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -393,7 +393,7 @@ describe API::Notes do put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/"\ "notes/#{merge_request_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -401,7 +401,7 @@ describe API::Notes do put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/"\ "notes/12345", user), body: "Hello!" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -412,17 +412,17 @@ describe API::Notes do delete api("/projects/#{project.id}/issues/#{issue.iid}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) # Check if note is really deleted delete api("/projects/#{project.id}/issues/#{issue.iid}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete api("/projects/#{project.id}/issues/#{issue.iid}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -435,18 +435,18 @@ describe API::Notes do delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) # Check if note is really deleted delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -459,18 +459,18 @@ describe API::Notes do delete api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.iid}/notes/#{merge_request_note.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) # Check if note is really deleted delete api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.iid}/notes/#{merge_request_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.iid}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do diff --git a/spec/requests/api/notification_settings_spec.rb b/spec/requests/api/notification_settings_spec.rb index 7968659a1ec..3273cd26690 100644 --- a/spec/requests/api/notification_settings_spec.rb +++ b/spec/requests/api/notification_settings_spec.rb @@ -9,7 +9,7 @@ describe API::NotificationSettings do it "returns global notification settings for the current user" do get api("/notification_settings", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash expect(json_response['notification_email']).to eq(user.notification_email) expect(json_response['level']).to eq(user.global_notification_setting.level) @@ -22,7 +22,7 @@ describe API::NotificationSettings do it "updates global notification settings for the current user" do put api("/notification_settings", user), { level: 'watch', notification_email: email.email } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['notification_email']).to eq(email.email) expect(user.reload.notification_email).to eq(email.email) expect(json_response['level']).to eq(user.reload.global_notification_setting.level) @@ -33,7 +33,7 @@ describe API::NotificationSettings do it "fails on non-user email address" do put api("/notification_settings", user), { notification_email: 'invalid@example.com' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -41,7 +41,7 @@ describe API::NotificationSettings do it "returns group level notification settings for the current user" do get api("/groups/#{group.id}/notification_settings", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash expect(json_response['level']).to eq(user.notification_settings_for(group).level) end @@ -51,7 +51,7 @@ describe API::NotificationSettings do it "updates group level notification settings for the current user" do put api("/groups/#{group.id}/notification_settings", user), { level: 'watch' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['level']).to eq(user.reload.notification_settings_for(group).level) end end @@ -60,7 +60,7 @@ describe API::NotificationSettings do it "returns project level notification settings for the current user" do get api("/projects/#{project.id}/notification_settings", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash expect(json_response['level']).to eq(user.notification_settings_for(project).level) end @@ -70,7 +70,7 @@ describe API::NotificationSettings do it "updates project level notification settings for the current user" do put api("/projects/#{project.id}/notification_settings", user), { level: 'custom', new_note: true } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['level']).to eq(user.reload.notification_settings_for(project).level) expect(json_response['events']['new_note']).to be_truthy expect(json_response['events']['new_issue']).to be_falsey @@ -81,7 +81,7 @@ describe API::NotificationSettings do it "fails on invalid level" do put api("/projects/#{project.id}/notification_settings", user), { level: 'invalid' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end diff --git a/spec/requests/api/oauth_tokens_spec.rb b/spec/requests/api/oauth_tokens_spec.rb index 0d56e1f732e..bdda80cc229 100644 --- a/spec/requests/api/oauth_tokens_spec.rb +++ b/spec/requests/api/oauth_tokens_spec.rb @@ -12,7 +12,7 @@ describe 'OAuth tokens' do request_oauth_token(user) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response['error']).to eq('invalid_grant') end end @@ -23,7 +23,7 @@ describe 'OAuth tokens' do request_oauth_token(user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['access_token']).not_to be_nil end end @@ -35,7 +35,7 @@ describe 'OAuth tokens' do request_oauth_token(user) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -46,7 +46,7 @@ describe 'OAuth tokens' do request_oauth_token(user) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/pages_domains_spec.rb b/spec/requests/api/pages_domains_spec.rb new file mode 100644 index 00000000000..d13b3a958c9 --- /dev/null +++ b/spec/requests/api/pages_domains_spec.rb @@ -0,0 +1,440 @@ +require 'rails_helper' + +describe API::PagesDomains do + set(:project) { create(:project) } + set(:user) { create(:user) } + + set(:pages_domain) { create(:pages_domain, domain: 'www.domain.test', project: project) } + set(:pages_domain_secure) { create(:pages_domain, :with_certificate, :with_key, domain: 'ssl.domain.test', project: project) } + set(:pages_domain_expired) { create(:pages_domain, :with_expired_certificate, :with_key, domain: 'expired.domain.test', project: project) } + + let(:pages_domain_params) { build(:pages_domain, domain: 'www.other-domain.test').slice(:domain) } + let(:pages_domain_secure_params) { build(:pages_domain, :with_certificate, :with_key, domain: 'ssl.other-domain.test', project: project).slice(:domain, :certificate, :key) } + let(:pages_domain_secure_key_missmatch_params) {build(:pages_domain, :with_trusted_chain, :with_key, project: project).slice(:domain, :certificate, :key) } + let(:pages_domain_secure_missing_chain_params) {build(:pages_domain, :with_missing_chain, project: project).slice(:certificate) } + + let(:route) { "/projects/#{project.id}/pages/domains" } + let(:route_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain.domain}" } + let(:route_secure_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain_secure.domain}" } + let(:route_expired_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain_expired.domain}" } + let(:route_vacant_domain) { "/projects/#{project.id}/pages/domains/www.vacant-domain.test" } + + before do + allow(Gitlab.config.pages).to receive(:enabled).and_return(true) + end + + describe 'GET /projects/:project_id/pages/domains' do + shared_examples_for 'get pages domains' do + it 'returns paginated pages domains' do + get api(route, user) + + expect(response).to have_gitlab_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.size).to eq(3) + expect(json_response.map { |pages_domain| pages_domain['domain'] }).to include(pages_domain.domain) + expect(json_response.last).to have_key('domain') + end + end + + context 'when pages is disabled' do + before do + allow(Gitlab.config.pages).to receive(:enabled).and_return(false) + project.add_master(user) + end + + it_behaves_like '404 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'get pages domains' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { get api(route, user) } + end + end + end + + describe 'GET /projects/:project_id/pages/domains/:domain' do + shared_examples_for 'get pages domain' do + it 'returns pages domain' do + get api(route_domain, user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['domain']).to eq(pages_domain.domain) + expect(json_response['url']).to eq(pages_domain.url) + expect(json_response['certificate']).to be_nil + end + + it 'returns pages domain with a certificate' do + get api(route_secure_domain, user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['domain']).to eq(pages_domain_secure.domain) + expect(json_response['url']).to eq(pages_domain_secure.url) + expect(json_response['certificate']['subject']).to eq(pages_domain_secure.subject) + expect(json_response['certificate']['expired']).to be false + end + + it 'returns pages domain with an expired certificate' do + get api(route_expired_domain, user) + + expect(response).to have_gitlab_http_status(200) + expect(json_response['certificate']['expired']).to be true + end + end + + context 'when domain is vacant' do + before do + project.add_master(user) + end + + it_behaves_like '404 response' do + let(:request) { get api(route_vacant_domain, user) } + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'get pages domain' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { get api(route, user) } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { get api(route, user) } + end + end + end + + describe 'POST /projects/:project_id/pages/domains' do + let(:params) { pages_domain_params.slice(:domain) } + let(:params_secure) { pages_domain_secure_params.slice(:domain, :certificate, :key) } + + shared_examples_for 'post pages domains' do + it 'creates a new pages domain' do + post api(route, user), params + pages_domain = PagesDomain.find_by(domain: json_response['domain']) + + expect(response).to have_gitlab_http_status(201) + expect(pages_domain.domain).to eq(params[:domain]) + expect(pages_domain.certificate).to be_nil + expect(pages_domain.key).to be_nil + end + + it 'creates a new secure pages domain' do + post api(route, user), params_secure + pages_domain = PagesDomain.find_by(domain: json_response['domain']) + + expect(response).to have_gitlab_http_status(201) + expect(pages_domain.domain).to eq(params_secure[:domain]) + expect(pages_domain.certificate).to eq(params_secure[:certificate]) + expect(pages_domain.key).to eq(params_secure[:key]) + end + + it 'fails to create pages domain without key' do + post api(route, user), pages_domain_secure_params.slice(:domain, :certificate) + + expect(response).to have_gitlab_http_status(400) + end + + it 'fails to create pages domain with key missmatch' do + post api(route, user), pages_domain_secure_key_missmatch_params.slice(:domain, :certificate, :key) + + expect(response).to have_gitlab_http_status(400) + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'post pages domains' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { post api(route, user), params } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { post api(route, user), params } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { post api(route, user), params } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { post api(route, user), params } + end + end + end + + describe 'PUT /projects/:project_id/pages/domains/:domain' do + let(:params_secure) { pages_domain_secure_params.slice(:certificate, :key) } + let(:params_secure_nokey) { pages_domain_secure_params.slice(:certificate) } + + shared_examples_for 'put pages domain' do + it 'updates pages domain removing certificate' do + put api(route_secure_domain, user) + pages_domain_secure.reload + + expect(response).to have_gitlab_http_status(200) + expect(pages_domain_secure.certificate).to be_nil + expect(pages_domain_secure.key).to be_nil + end + + it 'updates pages domain adding certificate' do + put api(route_domain, user), params_secure + pages_domain.reload + + expect(response).to have_gitlab_http_status(200) + expect(pages_domain.certificate).to eq(params_secure[:certificate]) + expect(pages_domain.key).to eq(params_secure[:key]) + end + + it 'updates pages domain with expired certificate' do + put api(route_expired_domain, user), params_secure + pages_domain_expired.reload + + expect(response).to have_gitlab_http_status(200) + expect(pages_domain_expired.certificate).to eq(params_secure[:certificate]) + expect(pages_domain_expired.key).to eq(params_secure[:key]) + end + + it 'updates pages domain with expired certificate not updating key' do + put api(route_secure_domain, user), params_secure_nokey + pages_domain_secure.reload + + expect(response).to have_gitlab_http_status(200) + expect(pages_domain_secure.certificate).to eq(params_secure_nokey[:certificate]) + end + + it 'fails to update pages domain adding certificate without key' do + put api(route_domain, user), params_secure_nokey + + expect(response).to have_gitlab_http_status(400) + end + + it 'fails to update pages domain adding certificate with missing chain' do + put api(route_domain, user), pages_domain_secure_missing_chain_params.slice(:certificate) + + expect(response).to have_gitlab_http_status(400) + end + + it 'fails to update pages domain with key missmatch' do + put api(route_secure_domain, user), pages_domain_secure_key_missmatch_params.slice(:certificate, :key) + + expect(response).to have_gitlab_http_status(400) + end + end + + context 'when domain is vacant' do + before do + project.add_master(user) + end + + it_behaves_like '404 response' do + let(:request) { put api(route_vacant_domain, user) } + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'put pages domain' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { put api(route_domain, user) } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { put api(route_domain, user) } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { put api(route_domain, user) } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { put api(route_domain, user) } + end + end + end + + describe 'DELETE /projects/:project_id/pages/domains/:domain' do + shared_examples_for 'delete pages domain' do + it 'deletes a pages domain' do + delete api(route_domain, user) + + expect(response).to have_gitlab_http_status(204) + end + end + + context 'when domain is vacant' do + before do + project.add_master(user) + end + + it_behaves_like '404 response' do + let(:request) { delete api(route_vacant_domain, user) } + end + end + + context 'when user is a master' do + before do + project.add_master(user) + end + + it_behaves_like 'delete pages domain' + end + + context 'when user is a developer' do + before do + project.add_developer(user) + end + + it_behaves_like '403 response' do + let(:request) { delete api(route_domain, user) } + end + end + + context 'when user is a reporter' do + before do + project.add_reporter(user) + end + + it_behaves_like '403 response' do + let(:request) { delete api(route_domain, user) } + end + end + + context 'when user is a guest' do + before do + project.add_guest(user) + end + + it_behaves_like '403 response' do + let(:request) { delete api(route_domain, user) } + end + end + + context 'when user is not a member' do + it_behaves_like '404 response' do + let(:request) { delete api(route_domain, user) } + end + end + end +end diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index f650df57383..7ea25059756 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -20,7 +20,7 @@ describe API::PipelineSchedules do it 'returns list of pipeline_schedules' do get api("/projects/#{project.id}/pipeline_schedules", developer) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(response).to match_response_schema('pipeline_schedules') end @@ -67,7 +67,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -75,7 +75,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -91,14 +91,14 @@ describe API::PipelineSchedules do it 'returns pipeline_schedule details' do get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline_schedule') end it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do get api("/projects/#{project.id}/pipeline_schedules/-5", developer) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -106,7 +106,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -118,7 +118,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -126,7 +126,7 @@ describe API::PipelineSchedules do it 'does not return pipeline_schedules list' do get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -142,7 +142,7 @@ describe API::PipelineSchedules do params end.to change { project.pipeline_schedules.count }.by(1) - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('pipeline_schedule') expect(json_response['description']).to eq(params[:description]) expect(json_response['ref']).to eq(params[:ref]) @@ -156,7 +156,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule' do post api("/projects/#{project.id}/pipeline_schedules", developer) - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -165,7 +165,7 @@ describe API::PipelineSchedules do post api("/projects/#{project.id}/pipeline_schedules", developer), params.merge('cron' => 'invalid-cron') - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('cron') end end @@ -175,7 +175,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule' do post api("/projects/#{project.id}/pipeline_schedules", user), params - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -183,7 +183,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule' do post api("/projects/#{project.id}/pipeline_schedules"), params - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -198,7 +198,7 @@ describe API::PipelineSchedules do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer), cron: '1 2 3 4 *' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline_schedule') expect(json_response['cron']).to eq('1 2 3 4 *') end @@ -208,7 +208,7 @@ describe API::PipelineSchedules do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer), cron: 'invalid-cron' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('cron') end end @@ -218,7 +218,7 @@ describe API::PipelineSchedules do it 'does not update pipeline_schedule' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -226,7 +226,7 @@ describe API::PipelineSchedules do it 'does not update pipeline_schedule' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -240,7 +240,7 @@ describe API::PipelineSchedules do it 'updates owner' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership", developer) - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('pipeline_schedule') end end @@ -249,7 +249,7 @@ describe API::PipelineSchedules do it 'does not update owner' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -257,7 +257,7 @@ describe API::PipelineSchedules do it 'does not update owner' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -279,13 +279,13 @@ describe API::PipelineSchedules do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", master) end.to change { project.pipeline_schedules.count }.by(-1) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do delete api("/projects/#{project.id}/pipeline_schedules/-5", master) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end it_behaves_like '412 response' do @@ -299,7 +299,7 @@ describe API::PipelineSchedules do it 'does not delete pipeline_schedule' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer) - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -307,7 +307,7 @@ describe API::PipelineSchedules do it 'does not delete pipeline_schedule' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -327,7 +327,7 @@ describe API::PipelineSchedules do params end.to change { pipeline_schedule.variables.count }.by(1) - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) expect(response).to match_response_schema('pipeline_schedule_variable') expect(json_response['key']).to eq(params[:key]) expect(json_response['value']).to eq(params[:value]) @@ -338,7 +338,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule_variable' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer) - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -347,7 +347,7 @@ describe API::PipelineSchedules do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer), params.merge('key' => '!?!?') - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) expect(json_response['message']).to have_key('key') end end @@ -357,7 +357,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule_variable' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", user), params - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -365,7 +365,7 @@ describe API::PipelineSchedules do it 'does not create pipeline_schedule_variable' do post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables"), params - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -384,7 +384,7 @@ describe API::PipelineSchedules do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", developer), value: 'updated_value' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to match_response_schema('pipeline_schedule_variable') expect(json_response['value']).to eq('updated_value') end @@ -394,7 +394,7 @@ describe API::PipelineSchedules do it 'does not update pipeline_schedule_variable' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", user) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -402,7 +402,7 @@ describe API::PipelineSchedules do it 'does not update pipeline_schedule_variable' do put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -428,14 +428,14 @@ describe API::PipelineSchedules do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", master) end.to change { Ci::PipelineScheduleVariable.count }.by(-1) - expect(response).to have_http_status(:accepted) + expect(response).to have_gitlab_http_status(:accepted) expect(response).to match_response_schema('pipeline_schedule_variable') end it 'responds with 404 Not Found if requesting non-existing pipeline_schedule_variable' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/____", master) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -445,7 +445,7 @@ describe API::PipelineSchedules do it 'does not delete pipeline_schedule_variable' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", developer) - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -453,7 +453,7 @@ describe API::PipelineSchedules do it 'does not delete pipeline_schedule_variable' do delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}") - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb index 258085e503f..e4dcc9252fa 100644 --- a/spec/requests/api/pipelines_spec.rb +++ b/spec/requests/api/pipelines_spec.rb @@ -19,7 +19,7 @@ describe API::Pipelines do it 'returns project pipelines' do get api("/projects/#{project.id}/pipelines", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['sha']).to match /\A\h{40}\z/ @@ -37,7 +37,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), scope: target - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty json_response.each { |r| expect(r['status']).to eq(target) } @@ -55,7 +55,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), scope: 'finished' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty json_response.each { |r| expect(r['status']).to be_in(%w[success failed canceled]) } @@ -70,7 +70,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), scope: 'branches' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty expect(json_response.last['id']).to eq(pipeline_branch.id) @@ -81,7 +81,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), scope: 'tags' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty expect(json_response.last['id']).to eq(pipeline_tag.id) @@ -93,7 +93,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), scope: 'invalid-scope' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -108,7 +108,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), status: target - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty json_response.each { |r| expect(r['status']).to eq(target) } @@ -120,7 +120,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), status: 'invalid-status' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end @@ -133,7 +133,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), ref: 'master' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty json_response.each { |r| expect(r['ref']).to eq('master') } @@ -144,7 +144,7 @@ describe API::Pipelines do it 'returns empty' do get api("/projects/#{project.id}/pipelines", user), ref: 'invalid-ref' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_empty end @@ -158,7 +158,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), name: user.name - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.first['id']).to eq(pipeline.id) end @@ -168,7 +168,7 @@ describe API::Pipelines do it 'returns empty' do get api("/projects/#{project.id}/pipelines", user), name: 'invalid-name' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_empty end @@ -182,7 +182,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), username: user.username - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.first['id']).to eq(pipeline.id) end @@ -192,7 +192,7 @@ describe API::Pipelines do it 'returns empty' do get api("/projects/#{project.id}/pipelines", user), username: 'invalid-username' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).to be_empty end @@ -207,7 +207,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), yaml_errors: true - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.first['id']).to eq(pipeline1.id) end @@ -217,7 +217,7 @@ describe API::Pipelines do it 'returns matched pipelines' do get api("/projects/#{project.id}/pipelines", user), yaml_errors: false - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response.first['id']).to eq(pipeline2.id) end @@ -227,7 +227,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), yaml_errors: 'invalid-yaml_errors' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -244,7 +244,7 @@ describe API::Pipelines do it 'sorts as user_id: :desc' do get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'desc' - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response).to include_pagination_headers expect(json_response).not_to be_empty @@ -257,7 +257,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), order_by: 'user_id', sort: 'invalid_sort' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -266,7 +266,7 @@ describe API::Pipelines do it 'returns bad_request' do get api("/projects/#{project.id}/pipelines", user), order_by: 'lock_version', sort: 'asc' - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -277,7 +277,7 @@ describe API::Pipelines do it 'does not return project pipelines' do get api("/projects/#{project.id}/pipelines", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -296,7 +296,7 @@ describe API::Pipelines do post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch end.to change { Ci::Pipeline.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to be_a Hash expect(json_response['sha']).to eq project.commit.id end @@ -304,7 +304,7 @@ describe API::Pipelines do it 'fails when using an invalid ref' do post api("/projects/#{project.id}/pipeline", user), ref: 'invalid_ref' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Reference not found' expect(json_response).not_to be_an Array end @@ -314,7 +314,7 @@ describe API::Pipelines do it 'fails to create pipeline' do post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Missing .gitlab-ci.yml file' expect(json_response).not_to be_an Array end @@ -325,7 +325,7 @@ describe API::Pipelines do it 'does not create pipeline' do post api("/projects/#{project.id}/pipeline", non_member), ref: project.default_branch - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -337,14 +337,14 @@ describe API::Pipelines do it 'returns project pipelines' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['sha']).to match /\A\h{40}\z/ end it 'returns 404 when it does not exist' do get api("/projects/#{project.id}/pipelines/123456", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Not found' expect(json_response['id']).to be nil end @@ -366,7 +366,7 @@ describe API::Pipelines do it 'should not return a project pipeline' do get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -387,7 +387,7 @@ describe API::Pipelines do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user) end.to change { pipeline.builds.count }.from(1).to(2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(build.reload.retried?).to be true end end @@ -396,7 +396,7 @@ describe API::Pipelines do it 'should not return a project pipeline' do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -415,7 +415,7 @@ describe API::Pipelines do it 'retries failed builds' do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('canceled') end end @@ -430,7 +430,7 @@ describe API::Pipelines do it 'rejects the action' do post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", reporter) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(pipeline.reload.status).to eq('pending') end end diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb index ac3bab09c4c..f31344a6238 100644 --- a/spec/requests/api/project_hooks_spec.rb +++ b/spec/requests/api/project_hooks_spec.rb @@ -22,7 +22,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns project hooks" do get api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response).to include_pagination_headers expect(json_response.count).to eq(1) @@ -43,7 +43,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "does not access project hooks" do get api("/projects/#{project.id}/hooks", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -53,7 +53,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a project hook" do get api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq(hook.url) expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['push_events']).to eq(hook.push_events) @@ -69,20 +69,20 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 404 error if hook id is not available" do get api("/projects/#{project.id}/hooks/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context "unauthorized user" do it "does not access an existing hook" do get api("/projects/#{project.id}/hooks/#{hook.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it "returns a 404 error if hook id is not available" do get api("/projects/#{project.id}/hooks/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -94,7 +94,7 @@ describe API::ProjectHooks, 'ProjectHooks' do job_events: true end.to change {project.hooks.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['url']).to eq('http://example.com') expect(json_response['issues_events']).to eq(true) expect(json_response['push_events']).to eq(true) @@ -115,7 +115,7 @@ describe API::ProjectHooks, 'ProjectHooks' do post api("/projects/#{project.id}/hooks", user), url: "http://example.com", token: token end.to change {project.hooks.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["url"]).to eq("http://example.com") expect(json_response).not_to include("token") @@ -127,12 +127,12 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 400 error if url not given" do post api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 422 error if url not valid" do post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com" - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -141,7 +141,7 @@ describe API::ProjectHooks, 'ProjectHooks' do put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'http://example.org', push_events: false, job_events: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq('http://example.org') expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['push_events']).to eq(false) @@ -159,7 +159,7 @@ describe API::ProjectHooks, 'ProjectHooks' do put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: "http://example.org", token: token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["url"]).to eq("http://example.org") expect(json_response).not_to include("token") @@ -169,17 +169,17 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns 404 error if hook id not found" do put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 400 error if url is not given" do put api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 422 error if url is not valid" do put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com' - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -188,19 +188,19 @@ describe API::ProjectHooks, 'ProjectHooks' do expect do delete api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change {project.hooks.count}.by(-1) end it "returns a 404 error when deleting non existent hook" do delete api("/projects/#{project.id}/hooks/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 404 error if hook id not given" do delete api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 404 if a user attempts to delete project hooks he/she does not own" do @@ -209,7 +209,7 @@ describe API::ProjectHooks, 'ProjectHooks' do other_project.team << [test_user, :master] delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(WebHook.exists?(hook.id)).to be_truthy end diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb index db34149eb73..e741ac4b7bd 100644 --- a/spec/requests/api/project_snippets_spec.rb +++ b/spec/requests/api/project_snippets_spec.rb @@ -12,7 +12,7 @@ describe API::ProjectSnippets do it 'exposes known attributes' do get api("/projects/#{project.id}/snippets/#{snippet.id}/user_agent_detail", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) @@ -21,7 +21,7 @@ describe API::ProjectSnippets do it "returns unautorized for non-admin users" do get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/user_agent_detail", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -36,7 +36,7 @@ describe API::ProjectSnippets do get api("/projects/#{project.id}/snippets", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(3) @@ -49,7 +49,7 @@ describe API::ProjectSnippets do get api("/projects/#{project.id}/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(0) @@ -63,7 +63,7 @@ describe API::ProjectSnippets do it 'returns snippet json' do get api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) expect(json_response['description']).to eq(snippet.description) @@ -73,7 +73,7 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do get api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end end @@ -92,7 +92,7 @@ describe API::ProjectSnippets do it 'creates a new snippet' do post api("/projects/#{project.id}/snippets/", admin), params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) snippet = ProjectSnippet.find(json_response['id']) expect(snippet.content).to eq(params[:code]) expect(snippet.description).to eq(params[:description]) @@ -106,7 +106,7 @@ describe API::ProjectSnippets do post api("/projects/#{project.id}/snippets/", admin), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -132,7 +132,7 @@ describe API::ProjectSnippets do expect { create_snippet(project, visibility: 'public') } .not_to change { Snippet.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -154,7 +154,7 @@ describe API::ProjectSnippets do put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content, description: new_description - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) snippet.reload expect(snippet.content).to eq(new_content) expect(snippet.description).to eq(new_description) @@ -163,14 +163,14 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do put api("/projects/#{snippet.project.id}/snippets/1234", admin), title: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put api("/projects/#{project.id}/snippets/1234", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -212,7 +212,7 @@ describe API::ProjectSnippets do expect { update_snippet(title: 'Foo', visibility: 'public') } .not_to change { snippet.reload.title } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -230,13 +230,13 @@ describe API::ProjectSnippets do it 'deletes snippet' do delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end it 'returns 404 for invalid snippet id' do delete api("/projects/#{snippet.project.id}/snippets/1234", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end @@ -251,7 +251,7 @@ describe API::ProjectSnippets do it 'returns raw text' do get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -259,7 +259,7 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do get api("/projects/#{snippet.project.id}/snippets/1234/raw", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 5964244f8c5..e095ba2af5d 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -45,7 +45,7 @@ describe API::Projects do it 'returns an array of projects' do get api('/projects', current_user), filter - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id)) @@ -147,7 +147,7 @@ describe API::Projects do it "does not include statistics by default" do get api('/projects', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first).not_to include('statistics') @@ -156,7 +156,7 @@ describe API::Projects do it "includes statistics if requested" do get api('/projects', user), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first).to include 'statistics' @@ -201,7 +201,7 @@ describe API::Projects do get api('/projects?simple=true', user) - expect(response).to have_http_status(200) + 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.keys).to match_array expected_keys @@ -228,7 +228,7 @@ describe API::Projects do it 'filters based on private visibility param' do get api('/projects', user), { visibility: 'private' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id, project2.id, project3.id) @@ -239,7 +239,7 @@ describe API::Projects do get api('/projects', user), { visibility: 'internal' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(project2.id) @@ -248,7 +248,7 @@ describe API::Projects do it 'filters based on public visibility param' do get api('/projects', user), { visibility: 'public' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(public_project.id) @@ -259,7 +259,7 @@ describe API::Projects do it 'returns the correct order when sorted by id' do get api('/projects', user), { order_by: 'id', sort: 'desc' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['id']).to eq(project3.id) @@ -270,7 +270,7 @@ describe API::Projects do it 'returns an array of projects the user owns' do get api('/projects', user4), owned: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['name']).to eq(project4.name) @@ -289,7 +289,7 @@ describe API::Projects do it 'returns the starred projects viewable by the user' do get api('/projects', user3), starred: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id) @@ -311,7 +311,7 @@ describe API::Projects do it 'returns only projects that satisfy all query parameters' do get api('/projects', user), { visibility: 'public', owned: true, starred: true, search: 'gitlab' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -330,7 +330,7 @@ describe API::Projects do it 'returns only projects that satisfy all query parameters' do get api('/projects', user), { visibility: 'public', membership: true, starred: true, search: 'gitlab' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(2) @@ -363,14 +363,14 @@ describe API::Projects do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) expect { post api('/projects', user2), name: 'foo' } .to change {Project.count}.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'creates new project without path but with name and returns 201' do expect { post api('/projects', user), name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -381,7 +381,7 @@ describe API::Projects do it 'creates new project without name but with path and returns 201' do expect { post api('/projects', user), path: 'foo_project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -392,7 +392,7 @@ describe API::Projects do it 'creates new project with name and path and returns 201' do expect { post api('/projects', user), path: 'path-project-Foo', name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -403,12 +403,12 @@ describe API::Projects do it 'creates last project before reaching project limit' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1) post api('/projects', user2), name: 'foo' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'does not create new project without name or path and returns 400' do expect { post api('/projects', user) }.not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "assigns attributes to project" do @@ -427,7 +427,7 @@ describe API::Projects do post api('/projects', user), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| next if %i[has_external_issue_tracker issues_enabled merge_requests_enabled wiki_enabled].include?(k) @@ -543,7 +543,7 @@ describe API::Projects do post api('/projects', user), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when a visibility level is restricted' do @@ -556,7 +556,7 @@ describe API::Projects do it 'does not allow a non-admin to use a restricted visibility level' do post api('/projects', user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['visibility_level'].first).to( match('restricted by your GitLab administrator') ) @@ -576,14 +576,14 @@ describe API::Projects do it 'returns error when user not found' do get api('/users/9999/projects/') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns projects filtered by user' do get api("/users/#{user4.id}/projects/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id) @@ -597,7 +597,7 @@ describe API::Projects do it 'creates new project without path but with name and return 201' do expect { post api("/projects/user/#{user.id}", admin), name: 'Foo Project' }.to change {Project.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.last @@ -608,7 +608,7 @@ describe API::Projects do it 'creates new project with name and path and returns 201' do expect { post api("/projects/user/#{user.id}", admin), path: 'path-project-Foo', name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.last @@ -620,7 +620,7 @@ describe API::Projects do expect { post api("/projects/user/#{user.id}", admin) } .not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end @@ -634,7 +634,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| next if %i[has_external_issue_tracker path].include?(k) expect(json_response[k.to_s]).to eq(v) @@ -646,7 +646,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['visibility']).to eq('public') end @@ -655,7 +655,7 @@ describe API::Projects do post api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['visibility']).to eq('internal') end @@ -720,7 +720,7 @@ describe API::Projects do it "uploads the file and returns its info" do post api("/projects/#{project.id}/uploads", user), file: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['alt']).to eq("dk") expect(json_response['url']).to start_with("/uploads/") expect(json_response['url']).to end_with("/dk.png") @@ -734,7 +734,7 @@ describe API::Projects do get api("/projects/#{public_project.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(public_project.id) expect(json_response['description']).to eq(public_project.description) expect(json_response['default_branch']).to eq(public_project.default_branch) @@ -754,7 +754,7 @@ describe API::Projects do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) @@ -798,20 +798,20 @@ describe API::Projects do it 'returns a project by path name' do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'returns a 404 error if not found' do get api('/projects/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'returns a 404 error if user is not a member' do other_user = create(:user) get api("/projects/#{project.id}", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'handles users with dots' do @@ -819,14 +819,14 @@ describe API::Projects do project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace) get api("/projects/#{CGI.escape(project.full_path)}", dot_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'exposes namespace fields' do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['namespace']).to eq({ 'id' => user.namespace.id, 'name' => user.namespace.name, @@ -840,28 +840,28 @@ describe API::Projects do it "does not include statistics by default" do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).not_to include 'statistics' end it "includes statistics if requested" do get api("/projects/#{project.id}", user), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to include 'statistics' end it "includes import_error if user can admin project" do get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to include("import_error") end it "does not include import_error if user cannot admin project" do get api("/projects/#{project.id}", user3) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).not_to include("import_error") end @@ -906,7 +906,7 @@ describe API::Projects do it 'contains permission information' do get api("/projects", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.first['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil @@ -918,7 +918,7 @@ describe API::Projects do project.team << [user, :master] get api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil @@ -935,7 +935,7 @@ describe API::Projects do it 'sets the owner and return 200' do get api("/projects/#{project2.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['group_access']['access_level']) .to eq(Gitlab::Access::OWNER) @@ -952,7 +952,7 @@ describe API::Projects do user = project.namespace.owner - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -981,7 +981,7 @@ describe API::Projects do it 'returns a 404 error if not found' do get api('/projects/42/users', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end @@ -990,7 +990,7 @@ describe API::Projects do get api("/projects/#{project.id}/users", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1003,7 +1003,7 @@ describe API::Projects do it 'returns an array of project snippets' do get api("/projects/#{project.id}/snippets", user) - expect(response).to have_http_status(200) + 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(snippet.title) @@ -1013,13 +1013,13 @@ describe API::Projects do describe 'GET /projects/:id/snippets/:snippet_id' do it 'returns a project snippet' do get api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) end it 'returns a 404 error if snippet id not found' do get api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1027,7 +1027,7 @@ describe API::Projects do it 'creates a new project snippet' do post api("/projects/#{project.id}/snippets", user), title: 'api test', file_name: 'sample.rb', code: 'test', visibility: 'private' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('api test') end @@ -1041,7 +1041,7 @@ describe API::Projects do it 'updates an existing project snippet' do put api("/projects/#{project.id}/snippets/#{snippet.id}", user), code: 'updated code' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('example') expect(snippet.reload.content).to eq('updated code') end @@ -1049,7 +1049,7 @@ describe API::Projects do it 'updates an existing project snippet with new title' do put api("/projects/#{project.id}/snippets/#{snippet.id}", user), title: 'other api test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('other api test') end end @@ -1063,13 +1063,13 @@ describe API::Projects do expect do delete api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Snippet.count }.by(-1) end it 'returns 404 when deleting unknown snippet id' do delete api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -1080,12 +1080,12 @@ describe API::Projects do describe 'GET /projects/:id/snippets/:snippet_id/raw' do it 'gets a raw project snippet' do get api("/projects/#{project.id}/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 404 error if raw project snippet not found' do get api("/projects/#{project.id}/snippets/5555/raw", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1098,13 +1098,13 @@ describe API::Projects do it "is not available for non admin users" do post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'allows project to be forked from an existing project' do expect(project_fork_target.forked?).not_to be_truthy post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked_project_link).not_to be_nil @@ -1121,7 +1121,7 @@ describe API::Projects do it 'fails if forked_from project which does not exist' do post api("/projects/#{project_fork_target.id}/fork/9999", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'fails with 409 if already forked' do @@ -1129,7 +1129,7 @@ describe API::Projects do project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) post api("/projects/#{project_fork_target.id}/fork/#{new_project_fork_source.id}", admin) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked?).to be_truthy @@ -1139,7 +1139,7 @@ describe API::Projects do describe 'DELETE /projects/:id/fork' do it "is not visible to users outside group" do delete api("/projects/#{project_fork_target.id}/fork", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'when users belong to project group' do @@ -1161,7 +1161,7 @@ describe API::Projects do it 'makes forked project unforked' do delete api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) project_fork_target.reload expect(project_fork_target.forked_from_project).to be_nil expect(project_fork_target.forked?).not_to be_truthy @@ -1174,13 +1174,13 @@ describe API::Projects do it 'is forbidden to non-owner users' do delete api("/projects/#{project_fork_target.id}/fork", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'is idempotent if not forked' do expect(project_fork_target.forked_from_project).to be_nil delete api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) expect(project_fork_target.reload.forked_from_project).to be_nil end end @@ -1210,7 +1210,7 @@ describe API::Projects do it 'returns the forks' do get api("/projects/#{project_fork_source.id}/forks", member) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(1) expect(json_response[0]['name']).to eq(private_fork.name) @@ -1221,7 +1221,7 @@ describe API::Projects do it 'returns an empty array' do get api("/projects/#{project_fork_source.id}/forks", non_member) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(0) end @@ -1232,7 +1232,7 @@ describe API::Projects do it 'returns an empty array' do get api("/projects/#{project_fork_source.id}/forks") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.length).to eq(0) end @@ -1250,7 +1250,7 @@ describe API::Projects do post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at end.to change { ProjectGroupLink.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['group_id']).to eq(group.id) expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['expires_at']).to eq(expires_at.to_s) @@ -1258,18 +1258,18 @@ describe API::Projects do it "returns a 400 error when group id is not given" do post api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when access level is not given" do post api("/projects/#{project.id}/share", user), group_id: group.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when sharing is disabled" do project.namespace.update(share_with_group_lock: true) post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when user cannot read group' do @@ -1277,19 +1277,19 @@ describe API::Projects do post api("/projects/#{project.id}/share", user), group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when group does not exist' do post api("/projects/#{project.id}/share", user), group_id: 1234, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 400 error when wrong params passed" do post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'group_access does not have a valid value' end end @@ -1305,7 +1305,7 @@ describe API::Projects do it 'returns 204 when deleting a group share' do delete api("/projects/#{project.id}/share/#{group.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(project.project_group_links).to be_empty end @@ -1317,19 +1317,19 @@ describe API::Projects do it 'returns a 400 when group id is not an integer' do delete api("/projects/#{project.id}/share/foo", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when group link does not exist' do delete api("/projects/#{project.id}/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when project does not exist' do delete api("/projects/123/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1350,7 +1350,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to match('at least one parameter must be provided') end @@ -1360,7 +1360,7 @@ describe API::Projects do put api("/projects/#{project.id}"), project_param - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1370,7 +1370,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1382,7 +1382,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1395,7 +1395,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1409,7 +1409,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['name']).to eq(['has already been taken']) end @@ -1418,7 +1418,7 @@ describe API::Projects do put api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['request_access_enabled']).to eq(false) end @@ -1427,7 +1427,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1439,7 +1439,7 @@ describe API::Projects do put api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) @@ -1451,7 +1451,7 @@ describe API::Projects do it 'updates path' do project_param = { path: 'bar' } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1465,7 +1465,7 @@ describe API::Projects do description: 'new description' } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1474,20 +1474,20 @@ describe API::Projects do it 'does not update path to existing path' do project_param = { path: project.path } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['path']).to eq(['has already been taken']) end it 'does not update name' do project_param = { name: 'bar' } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not update visibility_level' do project_param = { visibility: 'public' } put api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1501,7 +1501,7 @@ describe API::Projects do description: 'new description', request_access_enabled: true } put api("/projects/#{project.id}", user3), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1511,7 +1511,7 @@ describe API::Projects do it 'archives the project' do post api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1524,7 +1524,7 @@ describe API::Projects do it 'remains archived' do post api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1537,7 +1537,7 @@ describe API::Projects do it 'rejects the action' do post api("/projects/#{project.id}/archive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1547,7 +1547,7 @@ describe API::Projects do it 'remains unarchived' do post api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1560,7 +1560,7 @@ describe API::Projects do it 'unarchives the project' do post api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1573,7 +1573,7 @@ describe API::Projects do it 'rejects the action' do post api("/projects/#{project.id}/unarchive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1583,7 +1583,7 @@ describe API::Projects do it 'stars the project' do expect { post api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['star_count']).to eq(1) end end @@ -1597,7 +1597,7 @@ describe API::Projects do it 'does not modify the star count' do expect { post api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1612,7 +1612,7 @@ describe API::Projects do it 'unstars the project' do expect { post api("/projects/#{project.id}/unstar", user) }.to change { project.reload.star_count }.by(-1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['star_count']).to eq(0) end end @@ -1621,7 +1621,7 @@ describe API::Projects do it 'does not modify the star count' do expect { post api("/projects/#{project.id}/unstar", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1631,7 +1631,7 @@ describe API::Projects do it 'removes project' do delete api("/projects/#{project.id}", user) - expect(response).to have_http_status(202) + expect(response).to have_gitlab_http_status(202) expect(json_response['message']).to eql('202 Accepted') end @@ -1644,17 +1644,17 @@ describe API::Projects do user3 = create(:user) project.team << [user3, :developer] delete api("/projects/#{project.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not remove a non existing project' do delete api('/projects/1328', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not remove a project not attached to user' do delete api("/projects/#{project.id}", user2) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1662,13 +1662,13 @@ describe API::Projects do it 'removes any existing project' do delete api("/projects/#{project.id}", admin) - expect(response).to have_http_status(202) + expect(response).to have_gitlab_http_status(202) expect(json_response['message']).to eql('202 Accepted') end it 'does not remove a non existing project' do delete api('/projects/1328', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -1697,7 +1697,7 @@ describe API::Projects do it 'forks if user has sufficient access to project' do post api("/projects/#{project.id}/fork", user2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(project.name) expect(json_response['path']).to eq(project.path) expect(json_response['owner']['id']).to eq(user2.id) @@ -1710,7 +1710,7 @@ describe API::Projects do it 'forks if user is admin' do post api("/projects/#{project.id}/fork", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(project.name) expect(json_response['path']).to eq(project.path) expect(json_response['owner']['id']).to eq(admin.id) @@ -1724,14 +1724,14 @@ describe API::Projects do new_user = create(:user) post api("/projects/#{project.id}/fork", new_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'fails if forked project exists in the user namespace' do post api("/projects/#{project.id}/fork", user) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']['name']).to eq(['has already been taken']) expect(json_response['message']['path']).to eq(['has already been taken']) end @@ -1739,61 +1739,61 @@ describe API::Projects do it 'fails if project to fork from does not exist' do post api('/projects/424242/fork', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'forks with explicit own user namespace id' do post api("/projects/#{project.id}/fork", user2), namespace: user2.namespace.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'forks with explicit own user name as namespace' do post api("/projects/#{project.id}/fork", user2), namespace: user2.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'forks to another user when admin' do post api("/projects/#{project.id}/fork", admin), namespace: user2.username - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['owner']['id']).to eq(user2.id) end it 'fails if trying to fork to another user when not admin' do post api("/projects/#{project.id}/fork", user2), namespace: admin.namespace.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'fails if trying to fork to non-existent namespace' do post api("/projects/#{project.id}/fork", user2), namespace: 42424242 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Target Namespace Not Found') end it 'forks to owned group' do post api("/projects/#{project.id}/fork", user2), namespace: group2.name - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['namespace']['name']).to eq(group2.name) end it 'fails to fork to not owned group' do post api("/projects/#{project.id}/fork", user2), namespace: group.name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'forks to not owned group when admin' do post api("/projects/#{project.id}/fork", admin), namespace: group.name - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['namespace']['name']).to eq(group.name) end end @@ -1802,7 +1802,7 @@ describe API::Projects do it 'returns authentication error' do post api("/projects/#{project.id}/fork") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response['message']).to eq('401 Unauthorized') end end @@ -1821,7 +1821,7 @@ describe API::Projects do post api("/projects/#{project.id}/housekeeping", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when housekeeping lease is taken' do @@ -1830,7 +1830,7 @@ describe API::Projects do post api("/projects/#{project.id}/housekeeping", user) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to match(/Somebody already triggered housekeeping for this project/) end end @@ -1844,7 +1844,7 @@ describe API::Projects do it 'returns forbidden error' do post api("/projects/#{project.id}/housekeeping", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1852,7 +1852,7 @@ describe API::Projects do it 'returns authentication error' do post api("/projects/#{project.id}/housekeeping") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb index 1a0695615e3..9f2ff3b5af6 100644 --- a/spec/requests/api/repositories_spec.rb +++ b/spec/requests/api/repositories_spec.rb @@ -17,7 +17,7 @@ describe API::Repositories do it 'returns the repository tree' do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array @@ -106,7 +106,7 @@ describe API::Repositories do it 'returns blob attributes as json' do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['size']).to eq(111) expect(json_response['encoding']).to eq("base64") expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n") @@ -165,7 +165,7 @@ describe API::Repositories do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when sha does not exist' do @@ -218,7 +218,7 @@ describe API::Repositories do it 'returns the repository archive' do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data @@ -230,7 +230,7 @@ describe API::Repositories do it 'returns the repository archive archive.zip' do get api("/projects/#{project.id}/repository/archive.zip", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data @@ -242,7 +242,7 @@ describe API::Repositories do it 'returns the repository archive archive.tar.bz2' do get api("/projects/#{project.id}/repository/archive.tar.bz2", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data @@ -293,7 +293,7 @@ describe API::Repositories do it "compares branches" do get api(route, current_user), from: 'master', to: 'feature' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -301,7 +301,7 @@ describe API::Repositories do it "compares tags" do get api(route, current_user), from: 'v1.0.0', to: 'v1.1.0' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -309,7 +309,7 @@ describe API::Repositories do it "compares commits" do get api(route, current_user), from: sample_commit.id, to: sample_commit.parent_id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_falsey @@ -318,7 +318,7 @@ describe API::Repositories do it "compares commits in reverse order" do get api(route, current_user), from: sample_commit.parent_id, to: sample_commit.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end @@ -326,7 +326,7 @@ describe API::Repositories do it "compares same refs" do get api(route, current_user), from: 'master', to: 'master' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_truthy @@ -367,7 +367,7 @@ describe API::Repositories do it 'returns valid data' do get api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 5068df5b43a..5fd76fce7df 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -16,7 +16,7 @@ describe API::Runner do it 'returns 400 error' do post api('/runners') - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 end end @@ -24,7 +24,7 @@ describe API::Runner do it 'returns 403 error' do post api('/runners'), token: 'invalid' - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 end end @@ -34,7 +34,7 @@ describe API::Runner do runner = Ci::Runner.first - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(json_response['id']).to eq(runner.id) expect(json_response['token']).to eq(runner.token) expect(runner.run_untagged).to be true @@ -47,7 +47,7 @@ describe API::Runner do it 'creates runner' do post api('/runners'), token: project.runners_token - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(project.runners.size).to eq(1) expect(Ci::Runner.first.token).not_to eq(registration_token) expect(Ci::Runner.first.token).not_to eq(project.runners_token) @@ -60,7 +60,7 @@ describe API::Runner do post api('/runners'), token: registration_token, description: 'server.hostname' - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.description).to eq('server.hostname') end end @@ -70,7 +70,7 @@ describe API::Runner do post api('/runners'), token: registration_token, tag_list: 'tag1, tag2' - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.tag_list.sort).to eq(%w(tag1 tag2)) end end @@ -82,7 +82,7 @@ describe API::Runner do run_untagged: false, tag_list: ['tag'] - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.run_untagged).to be false expect(Ci::Runner.first.tag_list.sort).to eq(['tag']) end @@ -93,7 +93,7 @@ describe API::Runner do post api('/runners'), token: registration_token, run_untagged: false - expect(response).to have_http_status 404 + expect(response).to have_gitlab_http_status 404 end end end @@ -103,7 +103,7 @@ describe API::Runner do post api('/runners'), token: registration_token, locked: true - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.locked).to be true end end @@ -116,7 +116,7 @@ describe API::Runner do post api('/runners'), token: registration_token, info: { param => value } - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 expect(Ci::Runner.first.read_attribute(param.to_sym)).to eq(value) end end @@ -128,7 +128,7 @@ describe API::Runner do it 'returns 400 error' do delete api('/runners') - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 end end @@ -136,7 +136,7 @@ describe API::Runner do it 'returns 403 error' do delete api('/runners'), token: 'invalid' - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 end end @@ -146,7 +146,7 @@ describe API::Runner do it 'deletes Runner' do delete api('/runners'), token: runner.token - expect(response).to have_http_status 204 + expect(response).to have_gitlab_http_status 204 expect(Ci::Runner.count).to eq(0) end @@ -164,7 +164,7 @@ describe API::Runner do it 'returns 400 error' do post api('/runners/verify') - expect(response).to have_http_status :bad_request + expect(response).to have_gitlab_http_status :bad_request end end @@ -172,7 +172,7 @@ describe API::Runner do it 'returns 403 error' do post api('/runners/verify'), token: 'invalid-token' - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 end end @@ -180,7 +180,7 @@ describe API::Runner do it 'verifies Runner credentials' do post api('/runners/verify'), token: runner.token - expect(response).to have_http_status 200 + expect(response).to have_gitlab_http_status 200 end end end @@ -216,7 +216,7 @@ describe API::Runner do context 'when runner sends version in User-Agent' do context 'for stable version' do it 'gives 204 and set X-GitLab-Last-Update' do - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(response.header).to have_key('X-GitLab-Last-Update') end end @@ -225,7 +225,7 @@ describe API::Runner do let(:last_update) { runner.ensure_runner_queue_value } it 'gives 204 and set the same X-GitLab-Last-Update' do - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(response.header['X-GitLab-Last-Update']).to eq(last_update) end end @@ -235,7 +235,7 @@ describe API::Runner do let(:new_update) { runner.tick_runner_queue } it 'gives 204 and set a new X-GitLab-Last-Update' do - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(response.header['X-GitLab-Last-Update']).to eq(new_update) end end @@ -243,19 +243,19 @@ describe API::Runner do context 'when beta version is sent' do let(:user_agent) { 'gitlab-runner 9.0.0~beta.167.g2b2bacc (master; go1.7.4; linux/amd64)' } - it { expect(response).to have_http_status(204) } + it { expect(response).to have_gitlab_http_status(204) } end context 'when pre-9-0 version is sent' do let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0 (1-6-stable; go1.6.3; linux/amd64)' } - it { expect(response).to have_http_status(204) } + it { expect(response).to have_gitlab_http_status(204) } end context 'when pre-9-0 beta version is sent' do let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0~beta.167.g2b2bacc (master; go1.6.3; linux/amd64)' } - it { expect(response).to have_http_status(204) } + it { expect(response).to have_gitlab_http_status(204) } end end end @@ -264,7 +264,7 @@ describe API::Runner do it 'returns 400 error' do post api('/jobs/request') - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 end end @@ -272,7 +272,7 @@ describe API::Runner do it 'returns 403 error' do post api('/jobs/request'), token: 'invalid' - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 end end @@ -283,7 +283,7 @@ describe API::Runner do it 'returns 204 error' do request_job - expect(response).to have_http_status 204 + expect(response).to have_gitlab_http_status 204 end end @@ -365,7 +365,7 @@ describe API::Runner do it 'picks a job' do request_job info: { platform: :darwin } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(response.headers).not_to have_key('X-GitLab-Last-Update') expect(runner.reload.platform).to eq('darwin') expect(json_response['id']).to eq(job.id) @@ -390,7 +390,7 @@ describe API::Runner do it 'sets branch as ref_type' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['git_info']['ref_type']).to eq('tag') end end @@ -399,7 +399,7 @@ describe API::Runner do it 'sets tag as ref_type' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['git_info']['ref_type']).to eq('branch') end end @@ -415,7 +415,7 @@ describe API::Runner do it "updates provided Runner's parameter" do request_job info: { param => value } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(runner.reload.read_attribute(param.to_sym)).to eq(value) end end @@ -430,7 +430,7 @@ describe API::Runner do it 'returns a conflict' do request_job - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(response.headers).not_to have_key('X-GitLab-Last-Update') end end @@ -448,7 +448,7 @@ describe API::Runner do it 'returns dependent jobs' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(2) expect(json_response['dependencies']).to include( @@ -468,7 +468,7 @@ describe API::Runner do it 'returns dependent jobs' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies']).to include( @@ -494,7 +494,7 @@ describe API::Runner do it 'returns dependent jobs' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(test_job.id) expect(json_response['dependencies'].count).to eq(1) expect(json_response['dependencies'][0]).to include('id' => job2.id, 'name' => job2.name, 'token' => job2.token) @@ -518,7 +518,7 @@ describe API::Runner do it 'returns an empty array' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(empty_dependencies_job.id) expect(json_response['dependencies'].count).to eq(0) end @@ -537,7 +537,7 @@ describe API::Runner do it 'picks job' do request_job - expect(response).to have_http_status 201 + expect(response).to have_gitlab_http_status 201 end end @@ -571,7 +571,7 @@ describe API::Runner do it 'returns variables for triggers' do request_job - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['variables']).to include(*expected_variables) end end @@ -683,7 +683,7 @@ describe API::Runner do it 'updates a running build' do update_job(trace: 'BUILD TRACE UPDATED') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(job.reload.trace.raw).to eq 'BUILD TRACE UPDATED' end end @@ -702,7 +702,7 @@ describe API::Runner do it 'responds with forbidden' do update_job - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -871,7 +871,7 @@ describe API::Runner do it 'authorizes posting artifacts to running job' do authorize_artifacts_with_token_in_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(json_response['TempPath']).not_to be_nil end @@ -881,7 +881,7 @@ describe API::Runner do authorize_artifacts_with_token_in_params(filesize: 100) - expect(response).to have_http_status(413) + expect(response).to have_gitlab_http_status(413) end end @@ -889,7 +889,7 @@ describe API::Runner do it 'authorizes posting artifacts to running job' do authorize_artifacts_with_token_in_headers - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(json_response['TempPath']).not_to be_nil end @@ -899,7 +899,7 @@ describe API::Runner do authorize_artifacts_with_token_in_headers(filesize: 100) - expect(response).to have_http_status(413) + expect(response).to have_gitlab_http_status(413) end end @@ -907,7 +907,7 @@ describe API::Runner do it 'fails to authorize artifacts posting' do authorize_artifacts(token: job.project.runners_token) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -916,14 +916,14 @@ describe API::Runner do authorize_artifacts - expect(response).to have_http_status(500) + expect(response).to have_gitlab_http_status(500) end context 'authorization token is invalid' do it 'responds with forbidden' do authorize_artifacts(token: 'invalid', filesize: 100 ) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -958,14 +958,14 @@ describe API::Runner do it 'responds with forbidden' do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when job is running' do shared_examples 'successful artifacts upload' do it 'updates successfully' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -998,7 +998,7 @@ describe API::Runner do it 'responds with forbidden' do upload_artifacts(file_upload, headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.project.runners_token)) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1009,7 +1009,7 @@ describe API::Runner do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_http_status(413) + expect(response).to have_gitlab_http_status(413) end end @@ -1017,7 +1017,7 @@ describe API::Runner do it 'fails to post artifacts without file' do post api("/jobs/#{job.id}/artifacts"), {}, headers_with_token - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -1025,7 +1025,7 @@ describe API::Runner do it 'fails to post artifacts without GitLab-Workhorse' do post api("/jobs/#{job.id}/artifacts"), { token: job.token }, {} - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1047,7 +1047,7 @@ describe API::Runner do let(:expire_in) { '7 days' } it 'updates when specified' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(7.days.from_now) end end @@ -1056,7 +1056,7 @@ describe API::Runner do let(:expire_in) { nil } it 'ignores if not specified' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job.reload.artifacts_expire_at).to be_nil end @@ -1065,7 +1065,7 @@ describe API::Runner do let(:default_artifacts_expire_in) { '5 days' } it 'sets to application default' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(5.days.from_now) end end @@ -1074,7 +1074,7 @@ describe API::Runner do let(:default_artifacts_expire_in) { '0' } it 'does not set expire_in' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(job.reload.artifacts_expire_at).to be_nil end end @@ -1103,7 +1103,7 @@ describe API::Runner do end it 'stores artifacts and artifacts metadata' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(stored_artifacts_file.original_filename).to eq(artifacts.original_filename) expect(stored_metadata_file.original_filename).to eq(metadata.original_filename) expect(stored_artifacts_size).to eq(71759) @@ -1116,7 +1116,7 @@ describe API::Runner do end it 'is expected to respond with bad request' do - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'does not store metadata' do @@ -1141,7 +1141,7 @@ describe API::Runner do it' "fails to post artifacts for outside of tmp path"' do upload_artifacts(file_upload, headers_with_token) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -1171,7 +1171,7 @@ describe API::Runner do context 'when using job token' do it 'download artifacts' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers).to include download_headers end end @@ -1180,14 +1180,14 @@ describe API::Runner do let(:token) { job.project.runners_token } it 'responds with forbidden' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end context 'when job does not has artifacts' do it 'responds with not found' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb index 67907579225..fe38a7b3251 100644 --- a/spec/requests/api/runners_spec.rb +++ b/spec/requests/api/runners_spec.rb @@ -37,7 +37,7 @@ describe API::Runners do get api('/runners', user) shared = json_response.any? { |r| r['is_shared'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(shared).to be_falsey @@ -47,7 +47,7 @@ describe API::Runners do get api('/runners?scope=active', user) shared = json_response.any? { |r| r['is_shared'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(shared).to be_falsey @@ -55,7 +55,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api('/runners?scope=unknown', user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -63,7 +63,7 @@ describe API::Runners do it 'does not return runners' do get api('/runners') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -75,7 +75,7 @@ describe API::Runners do get api('/runners/all', admin) shared = json_response.any? { |r| r['is_shared'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(shared).to be_truthy @@ -86,7 +86,7 @@ describe API::Runners do it 'does not return runners list' do get api('/runners/all', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -94,7 +94,7 @@ describe API::Runners do get api('/runners/all?scope=specific', admin) shared = json_response.any? { |r| r['is_shared'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(shared).to be_falsey @@ -102,7 +102,7 @@ describe API::Runners do it 'avoids filtering if scope is invalid' do get api('/runners?scope=unknown', admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -110,7 +110,7 @@ describe API::Runners do it 'does not return runners' do get api('/runners') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -121,7 +121,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{shared_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq(shared_runner.description) end end @@ -130,7 +130,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{specific_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq(specific_runner.description) end end @@ -138,7 +138,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do get api('/runners/9999', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -147,7 +147,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{specific_runner.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq(specific_runner.description) end end @@ -156,7 +156,7 @@ describe API::Runners do it "returns runner's details" do get api("/runners/#{shared_runner.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq(shared_runner.description) end end @@ -166,7 +166,7 @@ describe API::Runners do it "does not return runner's details" do get api("/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -174,7 +174,7 @@ describe API::Runners do it "does not return runner's details" do get api("/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -195,7 +195,7 @@ describe API::Runners do access_level: 'ref_protected') shared_runner.reload - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(shared_runner.description).to eq("#{description}_updated") expect(shared_runner.active).to eq(!active) expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql') @@ -215,7 +215,7 @@ describe API::Runners do update_runner(specific_runner.id, admin, description: 'test') specific_runner.reload - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(specific_runner.description).to eq('test') expect(specific_runner.description).not_to eq(description) expect(specific_runner.ensure_runner_queue_value) @@ -226,7 +226,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do update_runner(9999, admin, description: 'test') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end def update_runner(id, user, args) @@ -239,7 +239,7 @@ describe API::Runners do it 'does not update runner' do put api("/runners/#{shared_runner.id}", user), description: 'test' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -247,7 +247,7 @@ describe API::Runners do it 'does not update runner without access to it' do put api("/runners/#{specific_runner.id}", user2), description: 'test' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'updates runner with access to it' do @@ -255,7 +255,7 @@ describe API::Runners do put api("/runners/#{specific_runner.id}", admin), description: 'test' specific_runner.reload - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(specific_runner.description).to eq('test') expect(specific_runner.description).not_to eq(description) end @@ -266,7 +266,7 @@ describe API::Runners do it 'does not delete runner' do put api("/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -278,7 +278,7 @@ describe API::Runners do expect do delete api("/runners/#{shared_runner.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Ci::Runner.shared.count }.by(-1) end @@ -292,7 +292,7 @@ describe API::Runners do expect do delete api("/runners/#{unused_specific_runner.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Ci::Runner.specific.count }.by(-1) end @@ -300,7 +300,7 @@ describe API::Runners do expect do delete api("/runners/#{specific_runner.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Ci::Runner.specific.count }.by(-1) end end @@ -308,7 +308,7 @@ describe API::Runners do it 'returns 404 if runner does not exists' do delete api('/runners/9999', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -316,26 +316,26 @@ describe API::Runners do context 'when runner is shared' do it 'does not delete runner' do delete api("/runners/#{shared_runner.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when runner is not shared' do it 'does not delete runner without access to it' do delete api("/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not delete runner with more than one associated project' do delete api("/runners/#{two_projects_runner.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'deletes runner for one owned project' do expect do delete api("/runners/#{specific_runner.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { Ci::Runner.specific.count }.by(-1) end @@ -349,7 +349,7 @@ describe API::Runners do it 'does not delete runner' do delete api("/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -360,7 +360,7 @@ describe API::Runners do get api("/projects/#{project.id}/runners", user) shared = json_response.any? { |r| r['is_shared'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(shared).to be_truthy @@ -371,7 +371,7 @@ describe API::Runners do it "does not return project's runners" do get api("/projects/#{project.id}/runners", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -379,7 +379,7 @@ describe API::Runners do it "does not return project's runners" do get api("/projects/#{project.id}/runners") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -396,14 +396,14 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id end.to change { project.runners.count }.by(+1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'avoids changes when enabling already enabled runner' do expect do post api("/projects/#{project.id}/runners", user), runner_id: specific_runner.id end.to change { project.runners.count }.by(0) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) end it 'does not enable locked runner' do @@ -413,13 +413,13 @@ describe API::Runners do post api("/projects/#{project.id}/runners", user), runner_id: specific_runner2.id end.to change { project.runners.count }.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not enable shared runner' do post api("/projects/#{project.id}/runners", user), runner_id: shared_runner.id - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'user is admin' do @@ -427,7 +427,7 @@ describe API::Runners do expect do post api("/projects/#{project.id}/runners", admin), runner_id: unused_specific_runner.id end.to change { project.runners.count }.by(+1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -435,14 +435,14 @@ describe API::Runners do it 'does not enable runner without access to' do post api("/projects/#{project.id}/runners", user), runner_id: unused_specific_runner.id - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'raises an error when no runner_id param is provided' do post api("/projects/#{project.id}/runners", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -450,7 +450,7 @@ describe API::Runners do it 'does not enable runner' do post api("/projects/#{project.id}/runners", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -458,7 +458,7 @@ describe API::Runners do it 'does not enable runner' do post api("/projects/#{project.id}/runners") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -470,7 +470,7 @@ describe API::Runners do expect do delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { project.runners.count }.by(-1) end @@ -484,14 +484,14 @@ describe API::Runners do expect do delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user) end.to change { project.runners.count }.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'returns 404 is runner is not found' do delete api("/projects/#{project.id}/runners/9999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -499,7 +499,7 @@ describe API::Runners do it "does not disable project's runner" do delete api("/projects/#{project.id}/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -507,7 +507,7 @@ describe API::Runners do it "does not disable project's runner" do delete api("/projects/#{project.id}/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb index 7e174903918..dfe48e45d49 100644 --- a/spec/requests/api/services_spec.rb +++ b/spec/requests/api/services_spec.rb @@ -16,7 +16,7 @@ describe API::Services do it "updates #{service} settings" do put api("/projects/#{project.id}/services/#{dashed_service}", user), service_attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) current_service = project.services.first event = current_service.event_names.empty? ? "foo" : current_service.event_names.first @@ -24,7 +24,7 @@ describe API::Services do put api("/projects/#{project.id}/services/#{dashed_service}?#{event}=#{!state}", user), service_attrs - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(project.services.first[event]).not_to eq(state) unless event == "foo" end @@ -56,7 +56,7 @@ describe API::Services do it "deletes #{service}" do delete api("/projects/#{project.id}/services/#{dashed_service}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) project.send(service_method).reload expect(project.send(service_method).activated?).to be_falsey end @@ -74,20 +74,20 @@ describe API::Services do it 'returns authentication error when unauthenticated' do get api("/projects/#{project.id}/services/#{dashed_service}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns all properties of service #{service} when authenticated as admin" do get api("/projects/#{project.id}/services/#{dashed_service}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list.map) end it "returns properties of service #{service} other than passwords when authenticated as project owner" do get api("/projects/#{project.id}/services/#{dashed_service}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['properties'].keys.map(&:to_sym)).to match_array(service_attrs_list_without_passwords) end @@ -95,7 +95,7 @@ describe API::Services do project.team << [user2, :developer] get api("/projects/#{project.id}/services/#{dashed_service}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -108,7 +108,7 @@ describe API::Services do it 'returns a not found message' do post api("/projects/#{project.id}/services/idonotexist/trigger") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["error"]).to eq("404 Not Found") end end @@ -127,7 +127,7 @@ describe API::Services do it 'when the service is inactive' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -142,7 +142,7 @@ describe API::Services do it 'returns status 200' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -150,7 +150,7 @@ describe API::Services do it 'returns a generic 404' do post api("/projects/404/services/#{service_name}/trigger"), params - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to eq("404 Service Not Found") end end @@ -170,7 +170,7 @@ describe API::Services do it 'returns status 200' do post api("/projects/#{project.id}/services/#{service_name}/trigger"), token: 'token', text: 'help' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['response_type']).to eq("ephemeral") end end diff --git a/spec/requests/api/session_spec.rb b/spec/requests/api/session_spec.rb index 5e77519c867..83d09878813 100644 --- a/spec/requests/api/session_spec.rb +++ b/spec/requests/api/session_spec.rb @@ -7,7 +7,7 @@ describe API::Session do context "when valid password" do it "returns private token" do post api("/session"), email: user.email, password: '12345678' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['email']).to eq(user.email) expect(json_response['private_token']).to eq(user.private_token) @@ -22,7 +22,7 @@ describe API::Session do post api('/session'), email: user.email, password: user.password - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(response.body).to include('You have 2FA enabled.') end end @@ -57,7 +57,7 @@ describe API::Session do context "when invalid password" do it "returns authentication error" do post api("/session"), email: user.email, password: '123' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response['email']).to be_nil expect(json_response['private_token']).to be_nil @@ -68,13 +68,13 @@ describe API::Session do it "returns authentication error with email" do post api("/session"), email: user.email - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns authentication error with username" do post api("/session"), email: user.username - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -82,7 +82,7 @@ describe API::Session do it "returns authentication error" do post api("/session"), password: user.password - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -91,7 +91,7 @@ describe API::Session do user.block post api("/session"), email: user.username, password: user.password - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -100,7 +100,7 @@ describe API::Session do user.ldap_block post api("/session"), email: user.username, password: user.password - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb index c24de58ee9d..5d3e78dd7c8 100644 --- a/spec/requests/api/settings_spec.rb +++ b/spec/requests/api/settings_spec.rb @@ -7,7 +7,7 @@ describe API::Settings, 'Settings' do describe "GET /application/settings" do it "returns application settings" do get api("/application/settings", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Hash expect(json_response['default_projects_limit']).to eq(42) expect(json_response['password_authentication_enabled']).to be_truthy @@ -56,7 +56,7 @@ describe API::Settings, 'Settings' do ed25519_key_restriction: 256, circuitbreaker_failure_wait_time: 2 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['default_projects_limit']).to eq(3) expect(json_response['password_authentication_enabled']).to be_falsey expect(json_response['repository_storages']).to eq(['custom']) @@ -83,7 +83,7 @@ describe API::Settings, 'Settings' do it "returns a blank parameter error message" do put api("/application/settings", admin), koding_enabled: true - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('koding_url is missing') end end @@ -92,7 +92,7 @@ describe API::Settings, 'Settings' do it "returns a blank parameter error message" do put api("/application/settings", admin), plantuml_enabled: true - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('plantuml_url is missing') end end diff --git a/spec/requests/api/sidekiq_metrics_spec.rb b/spec/requests/api/sidekiq_metrics_spec.rb index 83042d0cb12..fff9adb7f57 100644 --- a/spec/requests/api/sidekiq_metrics_spec.rb +++ b/spec/requests/api/sidekiq_metrics_spec.rb @@ -7,28 +7,28 @@ describe API::SidekiqMetrics do it 'defines the `queue_metrics` endpoint' do get api('/sidekiq/queue_metrics', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash end it 'defines the `process_metrics` endpoint' do get api('/sidekiq/process_metrics', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['processes']).to be_an Array end it 'defines the `job_stats` endpoint' do get api('/sidekiq/job_stats', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash end it 'defines the `compound_metrics` endpoint' do get api('/sidekiq/compound_metrics', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a Hash expect(json_response['queues']).to be_a Hash expect(json_response['processes']).to be_an Array diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb index d3905f698bd..74198c8eb4f 100644 --- a/spec/requests/api/snippets_spec.rb +++ b/spec/requests/api/snippets_spec.rb @@ -11,7 +11,7 @@ describe API::Snippets do get api("/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( @@ -27,7 +27,7 @@ describe API::Snippets do get api("/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(0) @@ -46,7 +46,7 @@ describe API::Snippets do it 'returns all snippets with public visibility from all users' do get api("/snippets/public", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( @@ -67,7 +67,7 @@ describe API::Snippets do it 'returns raw text' do get api("/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -75,7 +75,7 @@ describe API::Snippets do it 'returns 404 for invalid snippet id' do get api("/snippets/1234/raw", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end @@ -86,7 +86,7 @@ describe API::Snippets do it 'returns snippet json' do get api("/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) expect(json_response['description']).to eq(snippet.description) @@ -96,7 +96,7 @@ describe API::Snippets do it 'returns 404 for invalid snippet id' do get api("/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end end @@ -117,7 +117,7 @@ describe API::Snippets do post api("/snippets/", user), params end.to change { PersonalSnippet.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(params[:title]) expect(json_response['description']).to eq(params[:description]) expect(json_response['file_name']).to eq(params[:file_name]) @@ -128,7 +128,7 @@ describe API::Snippets do post api("/snippets/", user), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -152,7 +152,7 @@ describe API::Snippets do expect { create_snippet(visibility: 'public') } .not_to change { Snippet.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -177,7 +177,7 @@ describe API::Snippets do put api("/snippets/#{snippet.id}", user), content: new_content, description: new_description - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) snippet.reload expect(snippet.content).to eq(new_content) expect(snippet.description).to eq(new_description) @@ -186,21 +186,21 @@ describe API::Snippets do it 'returns 404 for invalid snippet id' do put api("/snippets/1234", user), title: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it "returns 404 for another user's snippet" do put api("/snippets/#{snippet.id}", other_user), title: 'fubar' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put api("/snippets/1234", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -228,7 +228,7 @@ describe API::Snippets do expect { update_snippet(title: 'Foo') } .not_to change { snippet.reload.title } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -260,14 +260,14 @@ describe API::Snippets do expect do delete api("/snippets/#{public_snippet.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { PersonalSnippet.count }.by(-1) end it 'returns 404 for invalid snippet id' do delete api("/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end @@ -284,7 +284,7 @@ describe API::Snippets do it 'exposes known attributes' do get api("/snippets/#{snippet.id}/user_agent_detail", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['user_agent']).to eq(user_agent_detail.user_agent) expect(json_response['ip_address']).to eq(user_agent_detail.ip_address) expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted) @@ -293,7 +293,7 @@ describe API::Snippets do it "returns unautorized for non-admin users" do get api("/snippets/#{snippet.id}/user_agent_detail", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index 216d278ad21..c7a009e999e 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -14,7 +14,7 @@ describe API::SystemHooks do it "returns authentication error" do get api("/hooks") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -22,7 +22,7 @@ describe API::SystemHooks do it "returns forbidden error" do get api("/hooks", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -30,7 +30,7 @@ describe API::SystemHooks do it "returns an array of hooks" do get api("/hooks", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['url']).to eq(hook.url) @@ -51,13 +51,13 @@ describe API::SystemHooks do it "responds with 400 if url not given" do post api("/hooks", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "responds with 400 if url is invalid" do post api("/hooks", admin), url: 'hp://mep.mep' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "does not create new hook without url" do @@ -69,7 +69,7 @@ describe API::SystemHooks do it 'sets default values for events' do post api('/hooks', admin), url: 'http://mep.mep', enable_ssl_verification: true - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['enable_ssl_verification']).to be true expect(json_response['tag_push_events']).to be false end @@ -78,13 +78,13 @@ describe API::SystemHooks do describe "GET /hooks/:id" do it "returns hook by id" do get api("/hooks/#{hook.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['event_name']).to eq('project_create') end it "returns 404 on failure" do get api("/hooks/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -93,14 +93,14 @@ describe API::SystemHooks do expect do delete api("/hooks/#{hook.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { SystemHook.count }.by(-1) end it 'returns 404 if the system hook does not exist' do delete api('/hooks/12345', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do diff --git a/spec/requests/api/templates_spec.rb b/spec/requests/api/templates_spec.rb index f8af9295842..de1619f33c1 100644 --- a/spec/requests/api/templates_spec.rb +++ b/spec/requests/api/templates_spec.rb @@ -23,7 +23,7 @@ describe API::Templates do it 'returns a list of available gitignore templates' do get api('/templates/gitignores') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to be > 15 @@ -34,7 +34,7 @@ describe API::Templates do it 'returns a list of available gitlab_ci_ymls' do get api('/templates/gitlab_ci_ymls') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['name']).not_to be_nil @@ -45,7 +45,7 @@ describe API::Templates do it 'adds a disclaimer on the top' do get api('/templates/gitlab_ci_ymls/Ruby') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['content']).to start_with("# This file is a template,") end end @@ -74,7 +74,7 @@ describe API::Templates do it 'returns a list of available license templates' do get api('/templates/licenses') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(12) @@ -86,7 +86,7 @@ describe API::Templates do it 'returns a list of available popular license templates' do get api('/templates/licenses?popular=1') - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(3) @@ -169,7 +169,7 @@ describe API::Templates do let(:license_type) { 'muth-over9000' } it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/todos_spec.rb b/spec/requests/api/todos_spec.rb index 25d7f6dffcf..c6063a2e089 100644 --- a/spec/requests/api/todos_spec.rb +++ b/spec/requests/api/todos_spec.rb @@ -110,7 +110,7 @@ describe API::Todos do it 'returns authentication error' do post api("/todos/#{pending_1.id}/mark_as_done") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -118,7 +118,7 @@ describe API::Todos do it 'marks a todo as done' do post api("/todos/#{pending_1.id}/mark_as_done", john_doe) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(pending_1.id) expect(json_response['state']).to eq('done') expect(pending_1.reload).to be_done @@ -137,7 +137,7 @@ describe API::Todos do it 'returns authentication error' do post api('/todos/mark_as_done') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -145,7 +145,7 @@ describe API::Todos do it 'marks all todos as done' do post api('/todos/mark_as_done', john_doe) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(pending_1.reload).to be_done expect(pending_2.reload).to be_done expect(pending_3.reload).to be_done @@ -196,9 +196,9 @@ describe API::Todos do post api("/projects/#{project_1.id}/#{issuable_type}/#{issuable.iid}/todo", guest) if issuable_type == 'merge_requests' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) else - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb index 922b99a6cba..b2c56f7af2c 100644 --- a/spec/requests/api/triggers_spec.rb +++ b/spec/requests/api/triggers_spec.rb @@ -28,13 +28,13 @@ describe API::Triggers do it 'returns bad request if token is missing' do post api("/projects/#{project.id}/trigger/pipeline"), ref: 'master' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns not found if project is not found' do post api('/projects/0/trigger/pipeline'), options.merge(ref: 'master') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -44,7 +44,7 @@ describe API::Triggers do it 'creates pipeline' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to include('id' => pipeline.id) pipeline.builds.reload expect(pipeline.builds.pending.size).to eq(2) @@ -54,7 +54,7 @@ describe API::Triggers do it 'returns bad request with no pipeline created if there\'s no commit for that ref' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'other-branch') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('base' => ["Reference not found"]) end @@ -66,21 +66,21 @@ describe API::Triggers do it 'validates variables to be a hash' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: 'value', ref: 'master') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('variables is invalid') end it 'validates variables needs to be a map of key-valued strings' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: { key: %w(1 2) }, ref: 'master') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('variables needs to be a map of key-valued strings') end it 'creates trigger request with variables' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(variables: variables, ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables) end end @@ -93,7 +93,7 @@ describe API::Triggers do it 'creates pipeline' do post api("/projects/#{project.id}/trigger/pipeline"), options.merge(ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to include('id' => pipeline.id) pipeline.builds.reload expect(pipeline.builds.pending.size).to eq(2) @@ -106,7 +106,7 @@ describe API::Triggers do it 'does not leak the presence of project when token is for different project' do post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'creates builds from the ref given in the URL, not in the body' do @@ -114,7 +114,7 @@ describe API::Triggers do post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(5) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when ref contains a dot' do @@ -125,7 +125,7 @@ describe API::Triggers do post api("/projects/#{project.id}/ref/v.1-branch/trigger/pipeline?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(4) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end end @@ -136,7 +136,7 @@ describe API::Triggers do it 'returns list of triggers' do get api("/projects/#{project.id}/triggers", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_a(Array) expect(json_response[0]).to have_key('token') @@ -147,7 +147,7 @@ describe API::Triggers do it 'does not return triggers list' do get api("/projects/#{project.id}/triggers", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -155,7 +155,7 @@ describe API::Triggers do it 'does not return triggers list' do get api("/projects/#{project.id}/triggers") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -165,14 +165,14 @@ describe API::Triggers do it 'returns trigger details' do get api("/projects/#{project.id}/triggers/#{trigger.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a(Hash) end it 'responds with 404 Not Found if requesting non-existing trigger' do get api("/projects/#{project.id}/triggers/-5", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -180,7 +180,7 @@ describe API::Triggers do it 'does not return triggers list' do get api("/projects/#{project.id}/triggers/#{trigger.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -188,7 +188,7 @@ describe API::Triggers do it 'does not return triggers list' do get api("/projects/#{project.id}/triggers/#{trigger.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -202,7 +202,7 @@ describe API::Triggers do description: 'trigger' end.to change {project.triggers.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to include('description' => 'trigger') end end @@ -211,7 +211,7 @@ describe API::Triggers do it 'does not create trigger' do post api("/projects/#{project.id}/triggers", user) - expect(response).to have_http_status(:bad_request) + expect(response).to have_gitlab_http_status(:bad_request) end end end @@ -221,7 +221,7 @@ describe API::Triggers do post api("/projects/#{project.id}/triggers", user2), description: 'trigger' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -230,7 +230,7 @@ describe API::Triggers do post api("/projects/#{project.id}/triggers"), description: 'trigger' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -243,7 +243,7 @@ describe API::Triggers do put api("/projects/#{project.id}/triggers/#{trigger.id}", user), description: new_description - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to include('description' => new_description) expect(trigger.reload.description).to eq(new_description) end @@ -253,7 +253,7 @@ describe API::Triggers do it 'does not update trigger' do put api("/projects/#{project.id}/triggers/#{trigger.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -261,7 +261,7 @@ describe API::Triggers do it 'does not update trigger' do put api("/projects/#{project.id}/triggers/#{trigger.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -271,7 +271,7 @@ describe API::Triggers do it 'updates owner' do post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to include('owner') expect(trigger.reload.owner).to eq(user) end @@ -281,7 +281,7 @@ describe API::Triggers do it 'does not update owner' do post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -289,7 +289,7 @@ describe API::Triggers do it 'does not update owner' do post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -300,14 +300,14 @@ describe API::Triggers do expect do delete api("/projects/#{project.id}/triggers/#{trigger.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change {project.triggers.count}.by(-1) end it 'responds with 404 Not Found if requesting non-existing trigger' do delete api("/projects/#{project.id}/triggers/-5", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it_behaves_like '412 response' do @@ -319,7 +319,7 @@ describe API::Triggers do it 'does not delete trigger' do delete api("/projects/#{project.id}/triggers/#{trigger.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -327,7 +327,7 @@ describe API::Triggers do it 'does not delete trigger' do delete api("/projects/#{project.id}/triggers/#{trigger.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 69c8aa4482a..4737f034f21 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -113,7 +113,7 @@ describe API::Users do it "returns a 403 when non-admin user searches by external UID" do get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}&provider=#{omniauth_user.identities.first.provider}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not reveal the `is_admin` flag of the user' do @@ -130,7 +130,7 @@ describe API::Users do admin_personal_access_token = create(:personal_access_token, user: admin).token get api("/users?private_token=#{admin_personal_access_token}&sudo=#{user.id}", admin) - expect(response).to have_http_status(:success) + expect(response).to have_gitlab_http_status(:success) end end @@ -162,13 +162,13 @@ describe API::Users do it "returns 400 error if provider with no extern_uid" do get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 error if provider with no extern_uid" do get api("/users?provider=#{omniauth_user.identities.first.provider}", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a user created before a specific date" do @@ -240,21 +240,21 @@ describe API::Users do get api("/users/#{user.id}") - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end it "returns a 404 error if user id not found" do get api("/users/9999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 for invalid ID" do get api("/users/1ASDF", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -271,7 +271,7 @@ describe API::Users do it "creates user with correct attributes" do post api('/users', admin), attributes_for(:user, admin: true, can_create_group: true) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) expect(new_user).not_to eq(nil) @@ -285,12 +285,12 @@ describe API::Users do post api('/users', admin), attributes - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it "creates non-admin user" do post api('/users', admin), attributes_for(:user, admin: false, can_create_group: false) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) expect(new_user).not_to eq(nil) @@ -300,7 +300,7 @@ describe API::Users do it "creates non-admin users by default" do post api('/users', admin), attributes_for(:user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) expect(new_user).not_to eq(nil) @@ -309,12 +309,12 @@ describe API::Users do it "returns 201 Created on success" do post api("/users", admin), attributes_for(:user, projects_limit: 3) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'creates non-external users by default' do post api("/users", admin), attributes_for(:user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -324,7 +324,7 @@ describe API::Users do it 'allows an external user to be created' do post api("/users", admin), attributes_for(:user, external: true) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -335,7 +335,7 @@ describe API::Users do it "creates user with reset password" do post api('/users', admin), attributes_for(:user, reset_password: true).except(:password) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) user_id = json_response['id'] new_user = User.find(user_id) @@ -349,27 +349,27 @@ describe API::Users do email: 'invalid email', password: 'password', name: 'test' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if name not given' do post api('/users', admin), attributes_for(:user).except(:name) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if password not given' do post api('/users', admin), attributes_for(:user).except(:password) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if email not given' do post api('/users', admin), attributes_for(:user).except(:email) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if username not given' do post api('/users', admin), attributes_for(:user).except(:username) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 error if user does not validate' do @@ -380,7 +380,7 @@ describe API::Users do name: 'test', bio: 'g' * 256, projects_limit: -1 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['password']) .to eq(['is too short (minimum is 8 characters)']) expect(json_response['message']['bio']) @@ -393,7 +393,7 @@ describe API::Users do it "is not available for non admin users" do post api("/users", user), attributes_for(:user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context 'with existing user' do @@ -413,7 +413,7 @@ describe API::Users do password: 'password', username: 'foo' end.to change { User.count }.by(0) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Email has already been taken') end @@ -425,14 +425,14 @@ describe API::Users do password: 'password', username: 'test' end.to change { User.count }.by(0) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to eq('Username has already been taken') end it 'creates user with new identity' do post api("/users", admin), attributes_for(:user, provider: 'github', extern_uid: '67890') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['identities'].first['extern_uid']).to eq('67890') expect(json_response['identities'].first['provider']).to eq('github') end @@ -450,7 +450,7 @@ describe API::Users do describe "GET /users/sign_up" do it "redirects to sign in page" do get "/users/sign_up" - expect(response).to have_http_status(302) + expect(response).to have_gitlab_http_status(302) expect(response).to redirect_to(new_user_session_path) end end @@ -465,7 +465,7 @@ describe API::Users do it "updates user with new bio" do put api("/users/#{user.id}", admin), { bio: 'new test bio' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['bio']).to eq('new test bio') expect(user.reload.bio).to eq('new test bio') end @@ -473,14 +473,14 @@ describe API::Users do it "updates user with new password and forces reset on next login" do put api("/users/#{user.id}", admin), password: '12345678' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.password_expires_at).to be <= Time.now end it "updates user with organization" do put api("/users/#{user.id}", admin), { organization: 'GitLab' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['organization']).to eq('GitLab') expect(user.reload.organization).to eq('GitLab') end @@ -491,14 +491,14 @@ describe API::Users do user.reload expect(user.avatar).to be_present - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['avatar_url']).to include(user.avatar_path) end it 'updates user with his own email' do put api("/users/#{user.id}", admin), email: user.email - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['email']).to eq(user.email) expect(user.reload.email).to eq(user.email) end @@ -506,14 +506,14 @@ describe API::Users do it 'updates user with a new email' do put api("/users/#{user.id}", admin), email: 'new@email.com' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.notification_email).to eq('new@email.com') end it 'updates user with his own username' do put api("/users/#{user.id}", admin), username: user.username - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['username']).to eq(user.username) expect(user.reload.username).to eq(user.username) end @@ -521,14 +521,14 @@ describe API::Users do it "updates user's existing identity" do put api("/users/#{omniauth_user.id}", admin), provider: 'ldapmain', extern_uid: '654321' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(omniauth_user.reload.identities.first.extern_uid).to eq('654321') end it 'updates user with new identity' do put api("/users/#{user.id}", admin), provider: 'github', extern_uid: 'john' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.identities.first.extern_uid).to eq('john') expect(user.reload.identities.first.provider).to eq('github') end @@ -536,7 +536,7 @@ describe API::Users do it "updates admin status" do put api("/users/#{user.id}", admin), { admin: true } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.admin).to eq(true) end @@ -551,7 +551,7 @@ describe API::Users do it "does not update admin status" do put api("/users/#{admin_user.id}", admin), { can_create_group: false } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(admin_user.reload.admin).to eq(true) expect(admin_user.can_create_group).to eq(false) end @@ -559,7 +559,7 @@ describe API::Users do it "does not allow invalid update" do put api("/users/#{user.id}", admin), { email: 'invalid email' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(user.reload.email).not_to eq('invalid email') end @@ -569,21 +569,21 @@ describe API::Users do put api("/users/#{user.id}", user), attributes_for(:user) end.not_to change { user.reload.attributes } - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it "returns 404 for non-existing user" do put api("/users/999999", admin), { bio: 'update should fail' } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 if invalid ID" do put api("/users/ASDF", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 400 error if user does not validate' do @@ -594,7 +594,7 @@ describe API::Users do name: 'test', bio: 'g' * 256, projects_limit: -1 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['password']) .to eq(['is too short (minimum is 8 characters)']) expect(json_response['message']['bio']) @@ -608,13 +608,13 @@ describe API::Users do it 'returns 400 if provider is missing for identity update' do put api("/users/#{omniauth_user.id}", admin), extern_uid: '654321' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 if external UID is missing for identity update' do put api("/users/#{omniauth_user.id}", admin), provider: 'ldap' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "with existing user" do @@ -627,7 +627,7 @@ describe API::Users do it 'returns 409 conflict error if email address exists' do put api("/users/#{@user.id}", admin), email: 'test@example.com' - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(@user.reload.email).to eq(@user.email) end @@ -635,7 +635,7 @@ describe API::Users do @user_id = User.all.last.id put api("/users/#{@user.id}", admin), username: 'test' - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(@user.reload.username).to eq(@user.username) end end @@ -649,14 +649,14 @@ describe API::Users do it "does not create invalid ssh key" do post api("/users/#{user.id}/keys", admin), { title: "invalid key" } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create key without title' do post api("/users/#{user.id}/keys", admin), key: 'some key' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end @@ -669,7 +669,7 @@ describe API::Users do it "returns 400 for invalid ID" do post api("/users/999999/keys", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -681,14 +681,14 @@ describe API::Users do context 'when unauthenticated' do it 'returns authentication error' do get api("/users/#{user.id}/keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing user' do get api('/users/999999/keys', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -698,7 +698,7 @@ describe API::Users do get api("/users/#{user.id}/keys", admin) - expect(response).to have_http_status(200) + 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) @@ -714,7 +714,7 @@ describe API::Users do context 'when unauthenticated' do it 'returns authentication error' do delete api("/users/#{user.id}/keys/42") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -726,7 +726,7 @@ describe API::Users do expect do delete api("/users/#{user.id}/keys/#{key.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.keys.count }.by(-1) end @@ -738,13 +738,13 @@ describe API::Users do user.keys << key user.save delete api("/users/999999/keys/#{key.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if key not foud' do delete api("/users/#{user.id}/keys/42", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Key Not Found') end end @@ -758,7 +758,7 @@ describe API::Users do it 'does not create invalid GPG key' do post api("/users/#{user.id}/gpg_keys", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end @@ -767,14 +767,14 @@ describe API::Users do expect do post api("/users/#{user.id}/gpg_keys", admin), key_attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { user.gpg_keys.count }.by(1) end it 'returns 400 for invalid ID' do post api('/users/999999/gpg_keys', admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -787,7 +787,7 @@ describe API::Users do it 'returns authentication error' do get api("/users/#{user.id}/gpg_keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -795,14 +795,14 @@ describe API::Users do it 'returns 404 for non-existing user' do get api('/users/999999/gpg_keys', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if key not foud' do delete api("/users/#{user.id}/gpg_keys/42", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end @@ -812,7 +812,7 @@ describe API::Users do get api("/users/#{user.id}/gpg_keys", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['key']).to eq(gpg_key.key) @@ -829,7 +829,7 @@ describe API::Users do it 'returns authentication error' do delete api("/users/#{user.id}/keys/42") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -841,7 +841,7 @@ describe API::Users do expect do delete api("/users/#{user.id}/gpg_keys/#{gpg_key.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.gpg_keys.count }.by(-1) end @@ -851,14 +851,14 @@ describe API::Users do delete api("/users/999999/gpg_keys/#{gpg_key.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if key not foud' do delete api("/users/#{user.id}/gpg_keys/42", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end end @@ -873,7 +873,7 @@ describe API::Users do it 'returns authentication error' do post api("/users/#{user.id}/gpg_keys/42/revoke") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -885,7 +885,7 @@ describe API::Users do expect do post api("/users/#{user.id}/gpg_keys/#{gpg_key.id}/revoke", admin) - expect(response).to have_http_status(:accepted) + expect(response).to have_gitlab_http_status(:accepted) end.to change { user.gpg_keys.count }.by(-1) end @@ -895,14 +895,14 @@ describe API::Users do post api("/users/999999/gpg_keys/#{gpg_key.id}/revoke", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if key not foud' do post api("/users/#{user.id}/gpg_keys/42/revoke", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end end @@ -916,7 +916,7 @@ describe API::Users do it "does not create invalid email" do post api("/users/#{user.id}/emails", admin), {} - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('email is missing') end @@ -930,7 +930,7 @@ describe API::Users do it "returns a 400 for invalid ID" do post api("/users/999999/emails", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -942,14 +942,14 @@ describe API::Users do context 'when unauthenticated' do it 'returns authentication error' do get api("/users/#{user.id}/emails") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing user' do get api('/users/999999/emails', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -959,7 +959,7 @@ describe API::Users do get api("/users/#{user.id}/emails", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['email']).to eq(email.email) @@ -968,7 +968,7 @@ describe API::Users do it "returns a 404 for invalid ID" do get api("/users/ASDF/emails", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -981,7 +981,7 @@ describe API::Users do context 'when unauthenticated' do it 'returns authentication error' do delete api("/users/#{user.id}/emails/42") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -993,7 +993,7 @@ describe API::Users do expect do delete api("/users/#{user.id}/emails/#{email.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.emails.count }.by(-1) end @@ -1005,20 +1005,20 @@ describe API::Users do user.emails << email user.save delete api("/users/999999/emails/#{email.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns 404 error if email not foud' do delete api("/users/#{user.id}/emails/42", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Email Not Found') end it "returns a 404 for invalid ID" do delete api("/users/ASDF/emails/bar", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1034,7 +1034,7 @@ describe API::Users do it "deletes user" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}", admin) } - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect { User.find(user.id) }.to raise_error ActiveRecord::RecordNotFound expect { Namespace.find(namespace.id) }.to raise_error ActiveRecord::RecordNotFound end @@ -1045,31 +1045,31 @@ describe API::Users do it "does not delete for unauthenticated user" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}") } - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "is not available for non admin users" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}", user) } - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 404 for non-existing user" do Sidekiq::Testing.inline! { delete api("/users/999999", admin) } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 for invalid ID" do Sidekiq::Testing.inline! { delete api("/users/ASDF", admin) } - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "hard delete disabled" do it "moves contributions to the ghost user" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}", admin) } - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(issue.reload).to be_persisted expect(issue.author.ghost?).to be_truthy end @@ -1079,7 +1079,7 @@ describe API::Users do it "removes contributions" do Sidekiq::Testing.inline! { delete api("/users/#{user.id}?hard_delete=true", admin) } - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(Issue.exists?(issue.id)).to be_falsy end end @@ -1093,7 +1093,7 @@ describe API::Users do it 'returns 403 without private token when sudo is defined' do get api("/user?private_token=#{personal_access_token}&sudo=123") - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1101,14 +1101,14 @@ describe API::Users do it 'returns 403 without private token when sudo defined' do get api("/user?private_token=#{user.private_token}&sudo=123") - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'returns current user without private token when sudo not defined' do get api("/user", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/user/public') expect(json_response['id']).to eq(user.id) end @@ -1128,13 +1128,13 @@ describe API::Users do it 'returns 403 without private token when sudo defined' do get api("/user?private_token=#{admin_personal_access_token}&sudo=#{user.id}") - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns initial current user without private token but with is_admin when sudo not defined' do get api("/user?private_token=#{admin_personal_access_token}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/user/admin') expect(json_response['id']).to eq(admin.id) end @@ -1144,7 +1144,7 @@ describe API::Users do it 'returns sudoed user with private token when sudo defined' do get api("/user?private_token=#{admin.private_token}&sudo=#{user.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/user/login') expect(json_response['id']).to eq(user.id) end @@ -1152,7 +1152,7 @@ describe API::Users do it 'returns initial current user without private token but with is_admin when sudo not defined' do get api("/user?private_token=#{admin.private_token}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/user/admin') expect(json_response['id']).to eq(admin.id) end @@ -1163,7 +1163,7 @@ describe API::Users do it "returns 401 error if user is unauthenticated" do get api("/user") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -1172,7 +1172,7 @@ describe API::Users do context "when unauthenticated" do it "returns authentication error" do get api("/user/keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1183,7 +1183,7 @@ describe API::Users do get api("/user/keys", user) - expect(response).to have_http_status(200) + 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) @@ -1203,14 +1203,14 @@ describe API::Users do user.keys << key user.save get api("/user/keys/#{key.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["title"]).to eq(key.title) end it "returns 404 Not Found within invalid ID" do get api("/user/keys/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Key Not Found') end @@ -1219,14 +1219,14 @@ describe API::Users do user.save admin get api("/user/keys/#{key.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Key Not Found') end it "returns 404 for invalid ID" do get api("/users/keys/ASDF", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "scopes" do @@ -1243,31 +1243,31 @@ describe API::Users do expect do post api("/user/keys", user), key_attrs end.to change { user.keys.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it "returns a 401 error if unauthorized" do post api("/user/keys"), title: 'some title', key: 'some key' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "does not create ssh key without key" do post api("/user/keys", user), title: 'title' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'does not create ssh key without title' do post api('/user/keys', user), key: 'some key' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end it "does not create ssh key without title" do post api("/user/keys", user), key: "somekey" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -1279,7 +1279,7 @@ describe API::Users do expect do delete api("/user/keys/#{key.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.keys.count}.by(-1) end @@ -1290,7 +1290,7 @@ describe API::Users do it "returns 404 if key ID not found" do delete api("/user/keys/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Key Not Found') end @@ -1298,13 +1298,13 @@ describe API::Users do user.keys << key user.save delete api("/user/keys/#{key.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns a 404 for invalid ID" do delete api("/users/keys/ASDF", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1313,7 +1313,7 @@ describe API::Users do it 'returns authentication error' do get api('/user/gpg_keys') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1324,7 +1324,7 @@ describe API::Users do get api('/user/gpg_keys', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['key']).to eq(gpg_key.key) @@ -1346,14 +1346,14 @@ describe API::Users do get api("/user/gpg_keys/#{gpg_key.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['key']).to eq(gpg_key.key) end it 'returns 404 Not Found within invalid ID' do get api('/user/gpg_keys/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end @@ -1363,14 +1363,14 @@ describe API::Users do get api("/user/gpg_keys/#{gpg_key.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end it 'returns 404 for invalid ID' do get api('/users/gpg_keys/ASDF', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'scopes' do @@ -1387,20 +1387,20 @@ describe API::Users do expect do post api('/user/gpg_keys', user), key_attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { user.gpg_keys.count }.by(1) end it 'returns a 401 error if unauthorized' do post api('/user/gpg_keys'), key: 'some key' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'does not create GPG key without key' do post api('/user/gpg_keys', user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end end @@ -1413,14 +1413,14 @@ describe API::Users do expect do post api("/user/gpg_keys/#{gpg_key.id}/revoke", user) - expect(response).to have_http_status(:accepted) + expect(response).to have_gitlab_http_status(:accepted) end.to change { user.gpg_keys.count}.by(-1) end it 'returns 404 if key ID not found' do post api('/user/gpg_keys/42/revoke', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end @@ -1430,13 +1430,13 @@ describe API::Users do post api("/user/gpg_keys/#{gpg_key.id}/revoke") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 404 for invalid ID' do post api('/users/gpg_keys/ASDF/revoke', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1448,14 +1448,14 @@ describe API::Users do expect do delete api("/user/gpg_keys/#{gpg_key.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.gpg_keys.count}.by(-1) end it 'returns 404 if key ID not found' do delete api('/user/gpg_keys/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 GPG Key Not Found') end @@ -1465,13 +1465,13 @@ describe API::Users do delete api("/user/gpg_keys/#{gpg_key.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 404 for invalid ID' do delete api('/users/gpg_keys/ASDF', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1479,7 +1479,7 @@ describe API::Users do context "when unauthenticated" do it "returns authentication error" do get api("/user/emails") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1490,7 +1490,7 @@ describe API::Users do get api("/user/emails", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first["email"]).to eq(email.email) @@ -1510,13 +1510,13 @@ describe API::Users do user.emails << email user.save get api("/user/emails/#{email.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["email"]).to eq(email.email) end it "returns 404 Not Found within invalid ID" do get api("/user/emails/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Email Not Found') end @@ -1525,14 +1525,14 @@ describe API::Users do user.save admin get api("/user/emails/#{email.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Email Not Found') end it "returns 404 for invalid ID" do get api("/users/emails/ASDF", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "scopes" do @@ -1549,18 +1549,18 @@ describe API::Users do expect do post api("/user/emails", user), email_attrs end.to change { user.emails.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it "returns a 401 error if unauthorized" do post api("/user/emails"), email: 'some email' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "does not create email with invalid email" do post api("/user/emails", user), {} - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('email is missing') end end @@ -1573,7 +1573,7 @@ describe API::Users do expect do delete api("/user/emails/#{email.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { user.emails.count}.by(-1) end @@ -1584,7 +1584,7 @@ describe API::Users do it "returns 404 if email ID not found" do delete api("/user/emails/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Email Not Found') end @@ -1592,13 +1592,13 @@ describe API::Users do user.emails << email user.save delete api("/user/emails/#{email.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns 400 for invalid ID" do delete api("/user/emails/ASDF", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -1609,25 +1609,25 @@ describe API::Users do it 'blocks existing user' do post api("/users/#{user.id}/block", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(user.reload.state).to eq('blocked') end it 'does not re-block ldap blocked users' do post api("/users/#{ldap_blocked_user.id}/block", admin) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(ldap_blocked_user.reload.state).to eq('ldap_blocked') end it 'does not be available for non admin users' do post api("/users/#{user.id}/block", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(user.reload.state).to eq('active') end it 'returns a 404 error if user id not found' do post api('/users/9999/block', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end end @@ -1641,38 +1641,38 @@ describe API::Users do it 'unblocks existing user' do post api("/users/#{user.id}/unblock", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(user.reload.state).to eq('active') end it 'unblocks a blocked user' do post api("/users/#{blocked_user.id}/unblock", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(blocked_user.reload.state).to eq('active') end it 'does not unblock ldap blocked users' do post api("/users/#{ldap_blocked_user.id}/unblock", admin) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(ldap_blocked_user.reload.state).to eq('ldap_blocked') end it 'does not be available for non admin users' do post api("/users/#{user.id}/unblock", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(user.reload.state).to eq('active') end it 'returns a 404 error if user id not found' do post api('/users/9999/block', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 for invalid ID" do post api("/users/ASDF/block", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1684,7 +1684,7 @@ describe API::Users do it 'has no permission' do get api("/user/activities", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1729,21 +1729,21 @@ describe API::Users do it 'returns a 404 error if user not found' do get api("/users/#{not_existing_user_id}/impersonation_tokens", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns a 403 error when authenticated as normal user' do get api("/users/#{not_existing_user_id}/impersonation_tokens", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') end it 'returns an array of all impersonated tokens' do get api("/users/#{user.id}/impersonation_tokens", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(2) @@ -1752,7 +1752,7 @@ describe API::Users do it 'returns an array of active impersonation tokens if state active' do get api("/users/#{user.id}/impersonation_tokens?state=active", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -1762,7 +1762,7 @@ describe API::Users do it 'returns an array of inactive personal access tokens if active is set to false' do get api("/users/#{user.id}/impersonation_tokens?state=inactive", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) expect(json_response).to all(include('active' => false)) @@ -1778,7 +1778,7 @@ describe API::Users do it 'returns validation error if impersonation token misses some attributes' do post api("/users/#{user.id}/impersonation_tokens", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end @@ -1787,7 +1787,7 @@ describe API::Users do name: name, expires_at: expires_at - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -1796,7 +1796,7 @@ describe API::Users do name: name, expires_at: expires_at - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') end @@ -1807,7 +1807,7 @@ describe API::Users do scopes: scopes, impersonation: impersonation - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq(name) expect(json_response['scopes']).to eq(scopes) expect(json_response['expires_at']).to eq(expires_at) @@ -1827,35 +1827,35 @@ describe API::Users do it 'returns 404 error if user not found' do get api("/users/#{not_existing_user_id}/impersonation_tokens/1", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns a 404 error if impersonation token not found' do get api("/users/#{user.id}/impersonation_tokens/#{not_existing_pat_id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Impersonation Token Not Found') end it 'returns a 404 error if token is not impersonation token' do get api("/users/#{user.id}/impersonation_tokens/#{personal_access_token.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Impersonation Token Not Found') end it 'returns a 403 error when authenticated as normal user' do get api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') end it 'returns a personal access token' do get api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['token']).to be_present expect(json_response['impersonation']).to be_truthy end @@ -1868,28 +1868,28 @@ describe API::Users do it 'returns a 404 error if user not found' do delete api("/users/#{not_existing_user_id}/impersonation_tokens/1", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it 'returns a 404 error if impersonation token not found' do delete api("/users/#{user.id}/impersonation_tokens/#{not_existing_pat_id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Impersonation Token Not Found') end it 'returns a 404 error if token is not impersonation token' do delete api("/users/#{user.id}/impersonation_tokens/#{personal_access_token.id}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Impersonation Token Not Found') end it 'returns a 403 error when authenticated as normal user' do delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response['message']).to eq('403 Forbidden') end @@ -1900,7 +1900,7 @@ describe API::Users do it 'revokes a impersonation token' do delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(impersonation_token.revoked).to be_falsey expect(impersonation_token.reload.revoked).to be_truthy end diff --git a/spec/requests/api/v3/award_emoji_spec.rb b/spec/requests/api/v3/award_emoji_spec.rb index 36d793f505d..0cd8b70007f 100644 --- a/spec/requests/api/v3/award_emoji_spec.rb +++ b/spec/requests/api/v3/award_emoji_spec.rb @@ -16,7 +16,7 @@ describe API::V3::AwardEmoji do it "returns an array of award_emoji" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(award_emoji.name) end @@ -24,7 +24,7 @@ describe API::V3::AwardEmoji do it "returns a 404 error when issue id not found" do get v3_api("/projects/#{project.id}/issues/12345/award_emoji", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -32,7 +32,7 @@ describe API::V3::AwardEmoji do it "returns an array of award_emoji" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['name']).to eq(downvote.name) @@ -46,7 +46,7 @@ describe API::V3::AwardEmoji do it 'returns the awarded emoji' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(award.name) end @@ -58,7 +58,7 @@ describe API::V3::AwardEmoji do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -69,7 +69,7 @@ describe API::V3::AwardEmoji do it 'returns an array of award emoji' do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(rocket.name) end @@ -80,7 +80,7 @@ describe API::V3::AwardEmoji do it "returns the award emoji" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/#{award_emoji.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(award_emoji.name) expect(json_response['awardable_id']).to eq(issue.id) expect(json_response['awardable_type']).to eq("Issue") @@ -89,7 +89,7 @@ describe API::V3::AwardEmoji do it "returns a 404 error if the award is not found" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -97,7 +97,7 @@ describe API::V3::AwardEmoji do it 'returns the award emoji' do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(downvote.name) expect(json_response['awardable_id']).to eq(merge_request.id) expect(json_response['awardable_type']).to eq("MergeRequest") @@ -111,7 +111,7 @@ describe API::V3::AwardEmoji do it 'returns the awarded emoji' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(award.name) expect(json_response['awardable_id']).to eq(snippet.id) expect(json_response['awardable_type']).to eq("Snippet") @@ -124,7 +124,7 @@ describe API::V3::AwardEmoji do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -135,7 +135,7 @@ describe API::V3::AwardEmoji do it 'returns an award emoji' do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji/#{rocket.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).not_to be_an Array expect(json_response['name']).to eq(rocket.name) end @@ -148,7 +148,7 @@ describe API::V3::AwardEmoji do it "creates a new award emoji" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user), name: 'blowfish' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') expect(json_response['user']['username']).to eq(user.username) end @@ -156,19 +156,19 @@ describe API::V3::AwardEmoji do it "returns a 400 bad request error if the name is not given" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if the user is not authenticated" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji"), name: 'thumbsup' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it "returns a 404 error if the user authored issue" do post v3_api("/projects/#{project.id}/issues/#{issue2.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "normalizes +1 as thumbsup award" do @@ -182,7 +182,7 @@ describe API::V3::AwardEmoji do post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user), name: 'thumbsup' post v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") end end @@ -194,7 +194,7 @@ describe API::V3::AwardEmoji do post v3_api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user), name: 'blowfish' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('blowfish') expect(json_response['user']['username']).to eq(user.username) end @@ -209,14 +209,14 @@ describe API::V3::AwardEmoji do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user), name: 'rocket' end.to change { note.award_emoji.count }.from(0).to(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['user']['username']).to eq(user.username) end it "it returns 404 error when user authored note" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note2.id}/award_emoji", user), name: 'thumbsup' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "normalizes +1 as thumbsup award" do @@ -230,7 +230,7 @@ describe API::V3::AwardEmoji do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user), name: 'rocket' post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji", user), name: 'rocket' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response["message"]).to match("has already been taken") end end @@ -242,14 +242,14 @@ describe API::V3::AwardEmoji do expect do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/#{award_emoji.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { issue.award_emoji.count }.from(1).to(0) end it 'returns a 404 error when the award emoji can not be found' do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/award_emoji/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -258,14 +258,14 @@ describe API::V3::AwardEmoji do expect do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/award_emoji/#{downvote.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { merge_request.award_emoji.count }.from(1).to(0) end it 'returns a 404 error when note id not found' do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -277,7 +277,7 @@ describe API::V3::AwardEmoji do expect do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { snippet.award_emoji.count }.from(1).to(0) end end @@ -290,7 +290,7 @@ describe API::V3::AwardEmoji do expect do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{note.id}/award_emoji/#{rocket.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { note.award_emoji.count }.from(1).to(0) end end diff --git a/spec/requests/api/v3/boards_spec.rb b/spec/requests/api/v3/boards_spec.rb index ea2627142bf..14409d25544 100644 --- a/spec/requests/api/v3/boards_spec.rb +++ b/spec/requests/api/v3/boards_spec.rb @@ -38,7 +38,7 @@ describe API::V3::Boards do it "returns authentication error" do get v3_api(base_url) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -46,7 +46,7 @@ describe API::V3::Boards do it "returns the project issue board" do get v3_api(base_url, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(board.id) @@ -63,7 +63,7 @@ describe API::V3::Boards do it 'returns issue board lists' do get v3_api(base_url, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['label']['name']).to eq(dev_label.title) @@ -72,7 +72,7 @@ describe API::V3::Boards do it 'returns 404 if board not found' do get v3_api("/projects/#{project.id}/boards/22343/lists", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -82,19 +82,19 @@ describe API::V3::Boards do it "rejects a non member from deleting a list" do delete v3_api("#{base_url}/#{dev_list.id}", non_member) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "rejects a user with guest role from deleting a list" do delete v3_api("#{base_url}/#{dev_list.id}", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 404 error if list id not found" do delete v3_api("#{base_url}/44444", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when the user is project owner" do @@ -107,7 +107,7 @@ describe API::V3::Boards do it "deletes the list if an admin requests it" do delete v3_api("#{base_url}/#{dev_list.id}", owner) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end diff --git a/spec/requests/api/v3/branches_spec.rb b/spec/requests/api/v3/branches_spec.rb index 9cd11a67712..1e038595a1f 100644 --- a/spec/requests/api/v3/branches_spec.rb +++ b/spec/requests/api/v3/branches_spec.rb @@ -17,7 +17,7 @@ describe API::V3::Branches do get v3_api("/projects/#{project.id}/repository/branches", user), per_page: 100 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array branch_names = json_response.map { |x| x['name'] } expect(branch_names).to match_array(project.repository.branch_names) @@ -32,20 +32,20 @@ describe API::V3::Branches do it "removes branch" do delete v3_api("/projects/#{project.id}/repository/branches/#{branch_name}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['branch_name']).to eq(branch_name) end it "removes a branch with dots in the branch name" do delete v3_api("/projects/#{project.id}/repository/branches/with.1.2.3", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['branch_name']).to eq("with.1.2.3") end it 'returns 404 if branch not exists' do delete v3_api("/projects/#{project.id}/repository/branches/foobar", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -57,13 +57,13 @@ describe API::V3::Branches do it 'returns 200' do delete v3_api("/projects/#{project.id}/repository/merged_branches", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 403 error if guest' do delete v3_api("/projects/#{project.id}/repository/merged_branches", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -73,7 +73,7 @@ describe API::V3::Branches do branch_name: 'feature1', ref: branch_sha - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('feature1') expect(json_response['commit']['id']).to eq(branch_sha) @@ -83,14 +83,14 @@ describe API::V3::Branches do post v3_api("/projects/#{project.id}/repository/branches", user2), branch_name: branch_name, ref: branch_sha - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns 400 if branch name is invalid' do post v3_api("/projects/#{project.id}/repository/branches", user), branch_name: 'new design', ref: branch_sha - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Branch name is invalid') end @@ -98,13 +98,13 @@ describe API::V3::Branches do post v3_api("/projects/#{project.id}/repository/branches", user), branch_name: 'new_design1', ref: branch_sha - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) post v3_api("/projects/#{project.id}/repository/branches", user), branch_name: 'new_design1', ref: branch_sha - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Branch already exists') end @@ -113,7 +113,7 @@ describe API::V3::Branches do branch_name: 'new_design3', ref: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Invalid reference name') end end diff --git a/spec/requests/api/v3/broadcast_messages_spec.rb b/spec/requests/api/v3/broadcast_messages_spec.rb index d04b1c72004..d9641011491 100644 --- a/spec/requests/api/v3/broadcast_messages_spec.rb +++ b/spec/requests/api/v3/broadcast_messages_spec.rb @@ -11,21 +11,21 @@ describe API::V3::BroadcastMessages do delete v3_api("/broadcast_messages/#{message.id}"), attributes_for(:broadcast_message) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 403 for users' do delete v3_api("/broadcast_messages/#{message.id}", user), attributes_for(:broadcast_message) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'deletes the broadcast message for admins' do expect do delete v3_api("/broadcast_messages/#{message.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { BroadcastMessage.count }.by(-1) end end diff --git a/spec/requests/api/v3/builds_spec.rb b/spec/requests/api/v3/builds_spec.rb index 0a2ff1058e3..3f58b7ef384 100644 --- a/spec/requests/api/v3/builds_spec.rb +++ b/spec/requests/api/v3/builds_spec.rb @@ -21,7 +21,7 @@ describe API::V3::Builds do context 'authorized user' do it 'returns project builds' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array end @@ -44,7 +44,7 @@ describe API::V3::Builds do let(:query) { 'scope=pending' } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -54,7 +54,7 @@ describe API::V3::Builds do let(:json_build) { json_response.first } it 'return builds with status skipped' do - expect(response).to have_http_status 200 + expect(response).to have_gitlab_http_status 200 expect(json_response).to be_an Array expect(json_response.length).to eq 1 expect(json_build['status']).to eq 'skipped' @@ -65,7 +65,7 @@ describe API::V3::Builds do let(:query) { 'scope[0]=pending&scope[1]=running' } it do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array end end @@ -73,7 +73,7 @@ describe API::V3::Builds do context 'respond 400 when scope contains invalid state' do let(:query) { 'scope[0]=pending&scope[1]=unknown_status' } - it { expect(response).to have_http_status(400) } + it { expect(response).to have_gitlab_http_status(400) } end end @@ -81,7 +81,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not return project builds' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -93,7 +93,7 @@ describe API::V3::Builds do end it 'responds with 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -109,7 +109,7 @@ describe API::V3::Builds do end it 'returns project jobs for specific commit' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq 2 @@ -132,7 +132,7 @@ describe API::V3::Builds do end it 'returns an empty array' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response).to be_empty end @@ -148,7 +148,7 @@ describe API::V3::Builds do end it 'does not return project jobs' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response.except('message')).to be_empty end end @@ -162,7 +162,7 @@ describe API::V3::Builds do context 'authorized user' do it 'returns specific job data' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('test') end @@ -180,7 +180,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not return specific job data' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -200,7 +200,7 @@ describe API::V3::Builds do end it 'returns specific job artifacts' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.headers).to include(download_headers) expect(response.body).to match_file(build.artifacts_file.file.file) end @@ -210,13 +210,13 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not return specific job artifacts' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end it 'does not return job artifacts if not uploaded' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -240,7 +240,7 @@ describe API::V3::Builds do end it 'gives 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -252,13 +252,13 @@ describe API::V3::Builds do end it 'gives 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'non-existing job' do shared_examples 'not found' do - it { expect(response).to have_http_status(:not_found) } + it { expect(response).to have_gitlab_http_status(:not_found) } end context 'has no such ref' do @@ -286,7 +286,7 @@ describe API::V3::Builds do "attachment; filename=#{build.artifacts_file.filename}" } end - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } it { expect(response.headers).to include(download_headers) } end @@ -327,7 +327,7 @@ describe API::V3::Builds do context 'authorized user' do it 'returns specific job trace' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.body).to eq(build.trace.raw) end end @@ -336,7 +336,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not return specific job trace' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -349,7 +349,7 @@ describe API::V3::Builds do context 'authorized user' do context 'user with :update_build persmission' do it 'cancels running or pending job' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(project.builds.first.status).to eq('canceled') end end @@ -358,7 +358,7 @@ describe API::V3::Builds do let(:api_user) { reporter.user } it 'does not cancel job' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -367,7 +367,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not cancel job' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -382,7 +382,7 @@ describe API::V3::Builds do context 'authorized user' do context 'user with :update_build permission' do it 'retries non-running job' do - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(project.builds.first.status).to eq('canceled') expect(json_response['status']).to eq('pending') end @@ -392,7 +392,7 @@ describe API::V3::Builds do let(:api_user) { reporter.user } it 'does not retry job' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -401,7 +401,7 @@ describe API::V3::Builds do let(:api_user) { nil } it 'does not retry job' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -471,7 +471,7 @@ describe API::V3::Builds do let(:build) { create(:ci_build, :manual, project: project, pipeline: pipeline) } it 'plays the job' do - expect(response).to have_http_status 200 + expect(response).to have_gitlab_http_status 200 expect(json_response['user']['id']).to eq(user.id) expect(json_response['id']).to eq(build.id) end @@ -479,7 +479,7 @@ describe API::V3::Builds do context 'on a non-playable job' do it 'returns a status code 400, Bad Request' do - expect(response).to have_http_status 400 + expect(response).to have_gitlab_http_status 400 expect(response.body).to match("Unplayable Job") end end diff --git a/spec/requests/api/v3/commits_spec.rb b/spec/requests/api/v3/commits_spec.rb index 6d0ca33a6fa..d31c94ddd2c 100644 --- a/spec/requests/api/v3/commits_spec.rb +++ b/spec/requests/api/v3/commits_spec.rb @@ -19,7 +19,7 @@ describe API::V3::Commits do commit = project.repository.commit get v3_api("/projects/#{project.id}/repository/commits", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['id']).to eq(commit.id) expect(json_response.first['committer_name']).to eq(commit.committer_name) @@ -30,7 +30,7 @@ describe API::V3::Commits do context "unauthorized user" do it "does not return project commits" do get v3_api("/projects/#{project.id}/repository/commits") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -69,7 +69,7 @@ describe API::V3::Commits do it "returns an invalid parameter error message" do get v3_api("/projects/#{project.id}/repository/commits?since=invalid-date", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('since is invalid') end end @@ -92,13 +92,13 @@ describe API::V3::Commits do it 'returns a 403 unauthorized for user without permissions' do post v3_api(url, user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'returns a 400 bad request if no params are given' do post v3_api(url, user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end describe 'create' do @@ -133,7 +133,7 @@ describe API::V3::Commits do it 'a new file in project repo' do post v3_api(url, user), valid_c_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) expect(json_response['committer_name']).to eq(user.name) expect(json_response['committer_email']).to eq(user.email) @@ -142,7 +142,7 @@ describe API::V3::Commits do it 'returns a 400 bad request if file exists' do post v3_api(url, user), invalid_c_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'with project path containing a dot in URL' do @@ -152,7 +152,7 @@ describe API::V3::Commits do it 'a new file in project repo' do post v3_api(url, user), valid_c_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end end @@ -187,14 +187,14 @@ describe API::V3::Commits do it 'an existing file in project repo' do post v3_api(url, user), valid_d_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post v3_api(url, user), invalid_d_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -232,14 +232,14 @@ describe API::V3::Commits do it 'an existing file in project repo' do post v3_api(url, user), valid_m_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post v3_api(url, user), invalid_m_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -275,14 +275,14 @@ describe API::V3::Commits do it 'an existing file in project repo' do post v3_api(url, user), valid_u_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'returns a 400 bad request if file does not exist' do post v3_api(url, user), invalid_u_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -348,14 +348,14 @@ describe API::V3::Commits do it 'are commited as one in project repo' do post v3_api(url, user), valid_mo_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(message) end it 'return a 400 bad request if there are any issues' do post v3_api(url, user), invalid_mo_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -365,7 +365,7 @@ describe API::V3::Commits do it "returns a commit by sha" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(project.repository.commit.id) expect(json_response['title']).to eq(project.repository.commit.title) expect(json_response['stats']['additions']).to eq(project.repository.commit.stats.additions) @@ -375,13 +375,13 @@ describe API::V3::Commits do it "returns a 404 error if not found" do get v3_api("/projects/#{project.id}/repository/commits/invalid_sha", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns nil for commit without CI" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to be_nil end @@ -391,7 +391,7 @@ describe API::V3::Commits do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq(pipeline.status) end @@ -400,7 +400,7 @@ describe API::V3::Commits do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq("created") end end @@ -408,7 +408,7 @@ describe API::V3::Commits do context "unauthorized user" do it "does not return the selected commit" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -419,7 +419,7 @@ describe API::V3::Commits do it "returns the diff of the selected commit" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to be >= 1 @@ -428,14 +428,14 @@ describe API::V3::Commits do it "returns a 404 error if invalid commit" do get v3_api("/projects/#{project.id}/repository/commits/invalid_sha/diff", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context "unauthorized user" do it "does not return the diff of the selected commit" do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/diff") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -444,7 +444,7 @@ describe API::V3::Commits do context 'authorized user' do it 'returns merge_request comments' do get v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['note']).to eq('a comment on a commit') @@ -453,14 +453,14 @@ describe API::V3::Commits do it 'returns a 404 error if merge_request_id not found' do get v3_api("/projects/#{project.id}/repository/commits/1234ab/comments", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context 'unauthorized user' do it 'does not return the diff of the selected commit' do get v3_api("/projects/#{project.id}/repository/commits/1234ab/comments") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -472,7 +472,7 @@ describe API::V3::Commits do it 'cherry picks a commit' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user), branch: 'master' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(master_pickable_commit.title) expect(json_response['message']).to eq(master_pickable_commit.cherry_pick_message(user)) expect(json_response['author_name']).to eq(master_pickable_commit.author_name) @@ -482,7 +482,7 @@ describe API::V3::Commits do it 'returns 400 if commit is already included in the target branch' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user), branch: 'markdown' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to include('Sorry, we cannot cherry-pick this commit automatically.') end @@ -492,35 +492,35 @@ describe API::V3::Commits do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user2), branch: protected_branch.name - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('You are not allowed to push into this branch') end it 'returns 400 for missing parameters' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('branch is missing') end it 'returns 404 if commit is not found' do post v3_api("/projects/#{project.id}/repository/commits/abcd0123/cherry_pick", user), branch: 'master' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Commit Not Found') end it 'returns 404 if branch is not found' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user), branch: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Branch Not Found') end it 'returns 400 for missing parameters' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('branch is missing') end end @@ -529,7 +529,7 @@ describe API::V3::Commits do it 'does not cherry pick the commit' do post v3_api("/projects/#{project.id}/repository/commits/#{master_pickable_commit.id}/cherry_pick"), branch: 'master' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -538,7 +538,7 @@ describe API::V3::Commits do context 'authorized user' do it 'returns comment' do post v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['note']).to eq('My comment') expect(json_response['path']).to be_nil expect(json_response['line']).to be_nil @@ -548,7 +548,7 @@ describe API::V3::Commits do it 'returns the inline comment' do post v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user), note: 'My comment', path: project.repository.commit.raw_diffs.first.new_path, line: 1, line_type: 'new' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['note']).to eq('My comment') expect(json_response['path']).to eq(project.repository.commit.raw_diffs.first.new_path) expect(json_response['line']).to eq(1) @@ -557,19 +557,19 @@ describe API::V3::Commits do it 'returns 400 if note is missing' do post v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 404 if note is attached to non existent commit' do post v3_api("/projects/#{project.id}/repository/commits/1234ab/comments", user), note: 'My comment' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context 'unauthorized user' do it 'does not return the diff of the selected commit' do post v3_api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}/comments") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/v3/deploy_keys_spec.rb b/spec/requests/api/v3/deploy_keys_spec.rb index 2affd0cfa51..785bc1eb4ba 100644 --- a/spec/requests/api/v3/deploy_keys_spec.rb +++ b/spec/requests/api/v3/deploy_keys_spec.rb @@ -46,7 +46,7 @@ describe API::V3::DeployKeys do it 'should return array of ssh keys' do get v3_api("/projects/#{project.id}/#{path}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['title']).to eq(deploy_key.title) end @@ -56,14 +56,14 @@ describe API::V3::DeployKeys do it 'should return a single key' do get v3_api("/projects/#{project.id}/#{path}/#{deploy_key.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(deploy_key.title) end it 'should return 404 Not Found with invalid ID' do get v3_api("/projects/#{project.id}/#{path}/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -71,14 +71,14 @@ describe API::V3::DeployKeys do it 'should not create an invalid ssh key' do post v3_api("/projects/#{project.id}/#{path}", admin), { title: 'invalid key' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('key is missing') end it 'should not create a key without title' do post v3_api("/projects/#{project.id}/#{path}", admin), key: 'some key' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('title is missing') end @@ -95,7 +95,7 @@ describe API::V3::DeployKeys do post v3_api("/projects/#{project.id}/#{path}", admin), { key: deploy_key.key, title: deploy_key.title } end.not_to change { project.deploy_keys.count } - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'joins an existing ssh key to a new project' do @@ -103,7 +103,7 @@ describe API::V3::DeployKeys do post v3_api("/projects/#{project2.id}/#{path}", admin), { key: deploy_key.key, title: deploy_key.title } end.to change { project2.deploy_keys.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'accepts can_push parameter' do @@ -111,7 +111,7 @@ describe API::V3::DeployKeys do post v3_api("/projects/#{project.id}/#{path}", admin), key_attrs - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['can_push']).to eq(true) end end @@ -128,7 +128,7 @@ describe API::V3::DeployKeys do it 'should return 404 Not Found with invalid ID' do delete v3_api("/projects/#{project.id}/#{path}/404", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -141,7 +141,7 @@ describe API::V3::DeployKeys do post v3_api("/projects/#{project2.id}/#{path}/#{deploy_key.id}/enable", admin) end.to change { project2.deploy_keys.count }.from(0).to(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['id']).to eq(deploy_key.id) end end @@ -150,7 +150,7 @@ describe API::V3::DeployKeys do it 'should return a 404 error' do post v3_api("/projects/#{project2.id}/#{path}/#{deploy_key.id}/enable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -162,7 +162,7 @@ describe API::V3::DeployKeys do delete v3_api("/projects/#{project.id}/#{path}/#{deploy_key.id}/disable", admin) end.to change { project.deploy_keys.count }.from(1).to(0) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(deploy_key.id) end end @@ -171,7 +171,7 @@ describe API::V3::DeployKeys do it 'should return a 404 error' do delete v3_api("/projects/#{project.id}/#{path}/#{deploy_key.id}/disable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/deployments_spec.rb b/spec/requests/api/v3/deployments_spec.rb index 0389a264781..90eabda4dac 100644 --- a/spec/requests/api/v3/deployments_spec.rb +++ b/spec/requests/api/v3/deployments_spec.rb @@ -30,7 +30,7 @@ describe API::V3::Deployments do it 'returns projects deployments' do get v3_api("/projects/#{project.id}/deployments", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) expect(json_response.first['iid']).to eq(deployment.iid) @@ -42,7 +42,7 @@ describe API::V3::Deployments do it 'returns a 404 status code' do get v3_api("/projects/#{project.id}/deployments", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -52,7 +52,7 @@ describe API::V3::Deployments do it 'returns the projects deployment' do get v3_api("/projects/#{project.id}/deployments/#{deployment.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['sha']).to match /\A\h{40}\z/ expect(json_response['id']).to eq(deployment.id) end @@ -62,7 +62,7 @@ describe API::V3::Deployments do it 'returns a 404 status code' do get v3_api("/projects/#{project.id}/deployments/#{deployment.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/environments_spec.rb b/spec/requests/api/v3/environments_spec.rb index 39264e819a3..937250b5219 100644 --- a/spec/requests/api/v3/environments_spec.rb +++ b/spec/requests/api/v3/environments_spec.rb @@ -36,7 +36,7 @@ describe API::V3::Environments do it 'returns project environments' do get v3_api("/projects/#{project.id}/environments", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) expect(json_response.first['name']).to eq(environment.name) @@ -50,7 +50,7 @@ describe API::V3::Environments do it 'returns a 404 status code' do get v3_api("/projects/#{project.id}/environments", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -60,7 +60,7 @@ describe API::V3::Environments do it 'creates a environment with valid params' do post v3_api("/projects/#{project.id}/environments", user), name: "mepmep" - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['name']).to eq('mepmep') expect(json_response['slug']).to eq('mepmep') expect(json_response['external']).to be nil @@ -69,19 +69,19 @@ describe API::V3::Environments do it 'requires name to be passed' do post v3_api("/projects/#{project.id}/environments", user), external_url: 'test.gitlab.com' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if environment already exists' do post v3_api("/projects/#{project.id}/environments", user), name: environment.name - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 if slug is specified' do post v3_api("/projects/#{project.id}/environments", user), name: "foo", slug: "foo" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") end end @@ -90,7 +90,7 @@ describe API::V3::Environments do it 'rejects the request' do post v3_api("/projects/#{project.id}/environments", non_member), name: 'gitlab.com' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 400 when the required params are missing' do @@ -105,7 +105,7 @@ describe API::V3::Environments do put v3_api("/projects/#{project.id}/environments/#{environment.id}", user), name: 'Mepmep', external_url: url - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') expect(json_response['external_url']).to eq(url) end @@ -115,7 +115,7 @@ describe API::V3::Environments do api_url = v3_api("/projects/#{project.id}/environments/#{environment.id}", user) put api_url, slug: slug + "-foo" - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed") end @@ -124,7 +124,7 @@ describe API::V3::Environments do put v3_api("/projects/#{project.id}/environments/#{environment.id}", user), name: 'Mepmep' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq('Mepmep') expect(json_response['external_url']).to eq(url) end @@ -132,7 +132,7 @@ describe API::V3::Environments do it 'returns a 404 if the environment does not exist' do put v3_api("/projects/#{project.id}/environments/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -141,13 +141,13 @@ describe API::V3::Environments do it 'returns a 200 for an existing environment' do delete v3_api("/projects/#{project.id}/environments/#{environment.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 404 for non existing id' do delete v3_api("/projects/#{project.id}/environments/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Not found') end end @@ -156,7 +156,7 @@ describe API::V3::Environments do it 'rejects the request' do delete v3_api("/projects/#{project.id}/environments/#{environment.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/files_spec.rb b/spec/requests/api/v3/files_spec.rb index dc7f0eefd16..5500c1cf770 100644 --- a/spec/requests/api/v3/files_spec.rb +++ b/spec/requests/api/v3/files_spec.rb @@ -36,7 +36,7 @@ describe API::V3::Files do it "returns file info" do get v3_api(route, current_user), params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(file_path) expect(json_response['file_name']).to eq('popen.rb') expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') @@ -112,7 +112,7 @@ describe API::V3::Files do it "creates a new file in project repo" do post v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['file_path']).to eq('newfile.rb') last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -122,7 +122,7 @@ describe API::V3::Files do it "returns a 400 bad request if no params given" do post v3_api("/projects/#{project.id}/repository/files", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 if editor fails to create file" do @@ -131,7 +131,7 @@ describe API::V3::Files do post v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -140,7 +140,7 @@ describe API::V3::Files do post v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) expect(last_commit.author_name).to eq(author_name) @@ -153,7 +153,7 @@ describe API::V3::Files do it "creates a new file in project repo" do post v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['file_path']).to eq('newfile.rb') last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -175,7 +175,7 @@ describe API::V3::Files do it "updates existing file in project repo" do put v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(file_path) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -185,7 +185,7 @@ describe API::V3::Files do it "returns a 400 bad request if no params given" do put v3_api("/projects/#{project.id}/repository/files", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -194,7 +194,7 @@ describe API::V3::Files do put v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) expect(last_commit.author_name).to eq(author_name) @@ -214,7 +214,7 @@ describe API::V3::Files do it "deletes existing file in project repo" do delete v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(file_path) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(user.email) @@ -224,7 +224,7 @@ describe API::V3::Files do it "returns a 400 bad request if no params given" do delete v3_api("/projects/#{project.id}/repository/files", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 if fails to delete file" do @@ -232,7 +232,7 @@ describe API::V3::Files do delete v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context "when specifying an author" do @@ -241,7 +241,7 @@ describe API::V3::Files do delete v3_api("/projects/#{project.id}/repository/files", user), valid_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) last_commit = project.repository.commit.raw expect(last_commit.author_email).to eq(author_email) expect(last_commit.author_name).to eq(author_name) @@ -274,7 +274,7 @@ describe API::V3::Files do it "remains unchanged" do get v3_api("/projects/#{project.id}/repository/files", user), get_params - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['file_path']).to eq(file_path) expect(json_response['file_name']).to eq(file_path) expect(json_response['content']).to eq(put_params[:content]) diff --git a/spec/requests/api/v3/groups_spec.rb b/spec/requests/api/v3/groups_spec.rb index 778fcc73c30..498cb42fad1 100644 --- a/spec/requests/api/v3/groups_spec.rb +++ b/spec/requests/api/v3/groups_spec.rb @@ -23,7 +23,7 @@ describe API::V3::Groups do it "returns authentication error" do get v3_api("/groups") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -31,7 +31,7 @@ describe API::V3::Groups do it "normal user: returns an array of groups of user1" do get v3_api("/groups", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response) @@ -41,7 +41,7 @@ describe API::V3::Groups do it "does not include statistics" do get v3_api("/groups", user1), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first).not_to include 'statistics' end @@ -51,7 +51,7 @@ describe API::V3::Groups do it "admin: returns an array of all groups" do get v3_api("/groups", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) end @@ -59,7 +59,7 @@ describe API::V3::Groups do it "does not include statistics by default" do get v3_api("/groups", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first).not_to include('statistics') end @@ -76,7 +76,7 @@ describe API::V3::Groups do get v3_api("/groups", admin), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response) .to satisfy_one { |group| group['statistics'] == attributes } @@ -87,7 +87,7 @@ describe API::V3::Groups do it "returns all groups excluding skipped groups" do get v3_api("/groups", admin), skip_groups: [group2.id] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) end @@ -101,7 +101,7 @@ describe API::V3::Groups do get v3_api("/groups", user1), all_available: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_groups).to contain_exactly(public_group.name, group1.name) end @@ -118,7 +118,7 @@ describe API::V3::Groups do it "sorts by name ascending by default" do get v3_api("/groups", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_groups).to eq([group3.name, group1.name]) end @@ -126,7 +126,7 @@ describe API::V3::Groups do it "sorts in descending order when passed" do get v3_api("/groups", user1), sort: "desc" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_groups).to eq([group1.name, group3.name]) end @@ -134,7 +134,7 @@ describe API::V3::Groups do it "sorts by the order_by param" do get v3_api("/groups", user1), order_by: "path" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_groups).to eq([group1.name, group3.name]) end @@ -146,7 +146,7 @@ describe API::V3::Groups do it 'returns authentication error' do get v3_api('/groups/owned') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -154,7 +154,7 @@ describe API::V3::Groups do it 'returns an array of groups the user owns' do get v3_api('/groups/owned', user2) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['name']).to eq(group2.name) @@ -170,7 +170,7 @@ describe API::V3::Groups do get v3_api("/groups/#{group1.id}", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(group1.id) expect(json_response['name']).to eq(group1.name) expect(json_response['path']).to eq(group1.path) @@ -192,13 +192,13 @@ describe API::V3::Groups do it "does not return a non existing group" do get v3_api("/groups/1328", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not return a group not attached to user1" do get v3_api("/groups/#{group2.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -206,14 +206,14 @@ describe API::V3::Groups do it "returns any existing group" do get v3_api("/groups/#{group2.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(group2.name) end it "does not return a non existing group" do get v3_api("/groups/1328", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -221,20 +221,20 @@ describe API::V3::Groups do it 'returns any existing group' do get v3_api("/groups/#{group1.path}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(group1.name) end it 'does not return a non existing group' do get v3_api('/groups/unknown', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not return a group not attached to user1' do get v3_api("/groups/#{group2.path}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -246,7 +246,7 @@ describe API::V3::Groups do it 'updates the group' do put v3_api("/groups/#{group1.id}", user1), name: new_group_name, request_access_enabled: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) expect(json_response['request_access_enabled']).to eq(true) end @@ -254,7 +254,7 @@ describe API::V3::Groups do it 'returns 404 for a non existing group' do put v3_api('/groups/1328', user1), name: new_group_name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -262,7 +262,7 @@ describe API::V3::Groups do it 'updates the group' do put v3_api("/groups/#{group1.id}", admin), name: new_group_name - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(new_group_name) end end @@ -271,7 +271,7 @@ describe API::V3::Groups do it 'does not updates the group' do put v3_api("/groups/#{group1.id}", user2), name: new_group_name - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -279,7 +279,7 @@ describe API::V3::Groups do it 'returns 404 when trying to update the group' do put v3_api("/groups/#{group2.id}", user1), name: new_group_name - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -289,7 +289,7 @@ describe API::V3::Groups do it "returns the group's projects" do get v3_api("/groups/#{group1.id}/projects", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(2) project_names = json_response.map { |proj| proj['name'] } expect(project_names).to match_array([project1.name, project3.name]) @@ -299,7 +299,7 @@ describe API::V3::Groups do it "returns the group's projects with simple representation" do get v3_api("/groups/#{group1.id}/projects", user1), simple: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(2) project_names = json_response.map { |proj| proj['name'] } expect(project_names).to match_array([project1.name, project3.name]) @@ -311,7 +311,7 @@ describe API::V3::Groups do get v3_api("/groups/#{group1.id}/projects", user1), visibility: 'public' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an(Array) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(public_project.name) @@ -320,13 +320,13 @@ describe API::V3::Groups do it "does not return a non existing group" do get v3_api("/groups/1328/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not return a group not attached to user1" do get v3_api("/groups/#{group2.id}/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "only returns projects to which user has access" do @@ -334,7 +334,7 @@ describe API::V3::Groups do get v3_api("/groups/#{group1.id}/projects", user3) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project3.name) end @@ -344,7 +344,7 @@ describe API::V3::Groups do get v3_api("/groups/#{project2.group.id}/projects", user3), owned: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project2.name) end @@ -354,7 +354,7 @@ describe API::V3::Groups do get v3_api("/groups/#{group1.id}/projects", user1), starred: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project1.name) end @@ -364,7 +364,7 @@ describe API::V3::Groups do it "returns any existing group" do get v3_api("/groups/#{group2.id}/projects", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.length).to eq(1) expect(json_response.first['name']).to eq(project2.name) end @@ -372,7 +372,7 @@ describe API::V3::Groups do it "does not return a non existing group" do get v3_api("/groups/1328/projects", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -380,7 +380,7 @@ describe API::V3::Groups do it 'returns any existing group' do get v3_api("/groups/#{group1.path}/projects", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_names = json_response.map { |proj| proj['name'] } expect(project_names).to match_array([project1.name, project3.name]) end @@ -388,13 +388,13 @@ describe API::V3::Groups do it 'does not return a non existing group' do get v3_api('/groups/unknown/projects', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not return a group not attached to user1' do get v3_api("/groups/#{group2.path}/projects", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -404,7 +404,7 @@ describe API::V3::Groups do it "does not create group" do post v3_api("/groups", user1), attributes_for(:group) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -414,7 +414,7 @@ describe API::V3::Groups do post v3_api("/groups", user3), group - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(group[:name]) expect(json_response["path"]).to eq(group[:path]) @@ -428,7 +428,7 @@ describe API::V3::Groups do post v3_api("/groups", user3), group - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["full_path"]).to eq("#{parent.path}/#{group[:path]}") expect(json_response["parent_id"]).to eq(parent.id) @@ -437,20 +437,20 @@ describe API::V3::Groups do it "does not create group, duplicate" do post v3_api("/groups", user3), { name: 'Duplicate Test', path: group2.path } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(response.message).to eq("Bad Request") end it "returns 400 bad request error if name not given" do post v3_api("/groups", user3), { path: group2.path } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 bad request error if path not given" do post v3_api("/groups", user3), { name: 'test' } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end @@ -460,7 +460,7 @@ describe API::V3::Groups do it "removes group" do delete v3_api("/groups/#{group1.id}", user1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "does not remove a group if not an owner" do @@ -469,19 +469,19 @@ describe API::V3::Groups do delete v3_api("/groups/#{group1.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "does not remove a non existing group" do delete v3_api("/groups/1328", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "does not remove a group not attached to user1" do delete v3_api("/groups/#{group2.id}", user1) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -489,13 +489,13 @@ describe API::V3::Groups do it "removes any existing group" do delete v3_api("/groups/#{group2.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "does not remove a non existing group" do delete v3_api("/groups/1328", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -513,7 +513,7 @@ describe API::V3::Groups do it "does not transfer project to group" do post v3_api("/groups/#{group1.id}/projects/#{project.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -521,7 +521,7 @@ describe API::V3::Groups do it "transfers project to group" do post v3_api("/groups/#{group1.id}/projects/#{project.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when using project path in URL' do @@ -529,7 +529,7 @@ describe API::V3::Groups do it "transfers project to group" do post v3_api("/groups/#{group1.id}/projects/#{project_path}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -537,7 +537,7 @@ describe API::V3::Groups do it "does not transfer project to group" do post v3_api("/groups/#{group1.id}/projects/nogroup%2Fnoproject", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -547,7 +547,7 @@ describe API::V3::Groups do it "transfers project to group" do post v3_api("/groups/#{group1.path}/projects/#{project_path}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end @@ -555,7 +555,7 @@ describe API::V3::Groups do it "does not transfer project to group" do post v3_api("/groups/noexist/projects/#{project_path}", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/issues_spec.rb b/spec/requests/api/v3/issues_spec.rb index 86768d7397a..39a47a62f16 100644 --- a/spec/requests/api/v3/issues_spec.rb +++ b/spec/requests/api/v3/issues_spec.rb @@ -59,7 +59,7 @@ describe API::V3::Issues, :mailer do it "returns authentication error" do get v3_api("/issues") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -67,7 +67,7 @@ describe API::V3::Issues, :mailer do it "returns an array of issues" do get v3_api("/issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['title']).to eq(issue.title) expect(json_response.last).to have_key('web_url') @@ -76,7 +76,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of closed issues' do get v3_api('/issues?state=closed', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(closed_issue.id) @@ -85,7 +85,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of opened issues' do get v3_api('/issues?state=opened', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(issue.id) @@ -94,7 +94,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of all issues' do get v3_api('/issues?state=all', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['id']).to eq(issue.id) @@ -104,7 +104,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled issues' do get v3_api("/issues?labels=#{label.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -113,7 +113,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled issues when at least one label matches' do get v3_api("/issues?labels=#{label.title},foo,bar", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -122,7 +122,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches labels' do get v3_api('/issues?labels=foo,bar', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -130,7 +130,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled issues matching given state' do get v3_api("/issues?labels=#{label.title}&state=opened", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -140,7 +140,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches labels and state filters' do get v3_api("/issues?labels=#{label.title}&state=closed", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -148,7 +148,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches milestone' do get v3_api("/issues?milestone=#{empty_milestone.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -156,7 +156,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if milestone does not exist' do get v3_api("/issues?milestone=foo", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -164,7 +164,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues in given milestone' do get v3_api("/issues?milestone=#{milestone.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['id']).to eq(issue.id) @@ -175,7 +175,7 @@ describe API::V3::Issues, :mailer do get v3_api("/issues?milestone=#{milestone.title}", user), '&state=closed' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(closed_issue.id) @@ -184,7 +184,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues with no milestone' do get v3_api("/issues?milestone=#{no_milestone_title}", author) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(confidential_issue.id) @@ -195,7 +195,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -205,7 +205,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -215,7 +215,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -225,7 +225,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -233,7 +233,7 @@ describe API::V3::Issues, :mailer do it 'matches V3 response schema' do get v3_api('/issues', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v3/issues') end end @@ -285,7 +285,7 @@ describe API::V3::Issues, :mailer do it 'returns all group issues (including opened and closed)' do get v3_api(base_url, admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) end @@ -293,7 +293,7 @@ describe API::V3::Issues, :mailer do it 'returns group issues without confidential issues for non project members' do get v3_api("#{base_url}?state=opened", non_member) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['title']).to eq(group_issue.title) @@ -302,7 +302,7 @@ describe API::V3::Issues, :mailer do it 'returns group confidential issues for author' do get v3_api("#{base_url}?state=opened", author) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) end @@ -310,7 +310,7 @@ describe API::V3::Issues, :mailer do it 'returns group confidential issues for assignee' do get v3_api("#{base_url}?state=opened", assignee) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) end @@ -318,7 +318,7 @@ describe API::V3::Issues, :mailer do it 'returns group issues with confidential issues for project members' do get v3_api("#{base_url}?state=opened", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) end @@ -326,7 +326,7 @@ describe API::V3::Issues, :mailer do it 'returns group confidential issues for admin' do get v3_api("#{base_url}?state=opened", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) end @@ -334,7 +334,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled group issues' do get v3_api("#{base_url}?labels=#{group_label.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['labels']).to eq([group_label.title]) @@ -343,7 +343,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled group issues where all labels match' do get v3_api("#{base_url}?labels=#{group_label.title},foo,bar", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -351,7 +351,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no group issue matches labels' do get v3_api("#{base_url}?labels=foo,bar", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -359,7 +359,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches milestone' do get v3_api("#{base_url}?milestone=#{group_empty_milestone.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -367,7 +367,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if milestone does not exist' do get v3_api("#{base_url}?milestone=foo", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -375,7 +375,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues in given milestone' do get v3_api("#{base_url}?state=opened&milestone=#{group_milestone.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(group_issue.id) @@ -385,7 +385,7 @@ describe API::V3::Issues, :mailer do get v3_api("#{base_url}?milestone=#{group_milestone.title}", user), '&state=closed' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(group_closed_issue.id) @@ -394,7 +394,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues with no milestone' do get v3_api("#{base_url}?milestone=#{no_milestone_title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(group_confidential_issue.id) @@ -405,7 +405,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -415,7 +415,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -425,7 +425,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -435,7 +435,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -447,7 +447,7 @@ describe API::V3::Issues, :mailer do it 'returns 404 when project does not exist' do get v3_api('/projects/1000/issues', non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 on private projects for other users" do @@ -456,7 +456,7 @@ describe API::V3::Issues, :mailer do get v3_api("/projects/#{private_project.id}/issues", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns no issues when user has access to project but not issues' do @@ -471,7 +471,7 @@ describe API::V3::Issues, :mailer do it 'returns project issues without confidential issues for non project members' do get v3_api("#{base_url}/issues", non_member) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['title']).to eq(issue.title) @@ -480,7 +480,7 @@ describe API::V3::Issues, :mailer do it 'returns project issues without confidential issues for project members with guest role' do get v3_api("#{base_url}/issues", guest) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['title']).to eq(issue.title) @@ -489,7 +489,7 @@ describe API::V3::Issues, :mailer do it 'returns project confidential issues for author' do get v3_api("#{base_url}/issues", author) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) expect(json_response.first['title']).to eq(issue.title) @@ -498,7 +498,7 @@ describe API::V3::Issues, :mailer do it 'returns project confidential issues for assignee' do get v3_api("#{base_url}/issues", assignee) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) expect(json_response.first['title']).to eq(issue.title) @@ -507,7 +507,7 @@ describe API::V3::Issues, :mailer do it 'returns project issues with confidential issues for project members' do get v3_api("#{base_url}/issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) expect(json_response.first['title']).to eq(issue.title) @@ -516,7 +516,7 @@ describe API::V3::Issues, :mailer do it 'returns project confidential issues for admin' do get v3_api("#{base_url}/issues", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) expect(json_response.first['title']).to eq(issue.title) @@ -525,7 +525,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled project issues' do get v3_api("#{base_url}/issues?labels=#{label.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -534,7 +534,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of labeled project issues where all labels match' do get v3_api("#{base_url}/issues?labels=#{label.title},foo,bar", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['labels']).to eq([label.title]) @@ -543,7 +543,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no project issue matches labels' do get v3_api("#{base_url}/issues?labels=foo,bar", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -551,7 +551,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if no issue matches milestone' do get v3_api("#{base_url}/issues?milestone=#{empty_milestone.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -559,7 +559,7 @@ describe API::V3::Issues, :mailer do it 'returns an empty array if milestone does not exist' do get v3_api("#{base_url}/issues?milestone=foo", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -567,7 +567,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues in given milestone' do get v3_api("#{base_url}/issues?milestone=#{milestone.title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['id']).to eq(issue.id) @@ -578,7 +578,7 @@ describe API::V3::Issues, :mailer do get v3_api("#{base_url}/issues?milestone=#{milestone.title}", user), '&state=closed' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(closed_issue.id) @@ -587,7 +587,7 @@ describe API::V3::Issues, :mailer do it 'returns an array of issues with no milestone' do get v3_api("#{base_url}/issues?milestone=#{no_milestone_title}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(confidential_issue.id) @@ -598,7 +598,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -608,7 +608,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['created_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -618,7 +618,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort.reverse) end @@ -628,7 +628,7 @@ describe API::V3::Issues, :mailer do response_dates = json_response.map { |issue| issue['updated_at'] } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(response_dates).to eq(response_dates.sort) end @@ -638,7 +638,7 @@ describe API::V3::Issues, :mailer do it 'exposes known attributes' do get v3_api("/projects/#{project.id}/issues/#{issue.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(issue.id) expect(json_response['iid']).to eq(issue.iid) expect(json_response['project_id']).to eq(issue.project.id) @@ -657,7 +657,7 @@ describe API::V3::Issues, :mailer do it "returns a project issue by id" do get v3_api("/projects/#{project.id}/issues/#{issue.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(issue.title) expect(json_response['iid']).to eq(issue.iid) end @@ -682,26 +682,26 @@ describe API::V3::Issues, :mailer do it "returns 404 if issue id not found" do get v3_api("/projects/#{project.id}/issues/54321", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'confidential issues' do it "returns 404 for non project members" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 for project members with guest role" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", guest) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns confidential issue for project members" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -709,7 +709,7 @@ describe API::V3::Issues, :mailer do it "returns confidential issue for author" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", author) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -717,7 +717,7 @@ describe API::V3::Issues, :mailer do it "returns confidential issue for assignee" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", assignee) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -725,7 +725,7 @@ describe API::V3::Issues, :mailer do it "returns confidential issue for admin" do get v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(confidential_issue.title) expect(json_response['iid']).to eq(confidential_issue.iid) end @@ -737,7 +737,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', labels: 'label, label2', assignee_id: assignee.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['description']).to be_nil expect(json_response['labels']).to eq(%w(label label2)) @@ -749,7 +749,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: true - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_truthy end @@ -758,7 +758,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: 'y' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_truthy end @@ -767,7 +767,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: false - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['confidential']).to be_falsy end @@ -776,7 +776,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', confidential: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end @@ -795,7 +795,7 @@ describe API::V3::Issues, :mailer do it "returns a 400 bad request if title not given" do post v3_api("/projects/#{project.id}/issues", user), labels: 'label, label2' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'allows special label names' do @@ -815,7 +815,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'g' * 256 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' ]) @@ -834,7 +834,7 @@ describe API::V3::Issues, :mailer do end it 'creates a new project issue' do - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) end it 'resolves the discussions in a merge request' do @@ -855,7 +855,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', due_date: due_date - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new issue') expect(json_response['description']).to be_nil expect(json_response['due_date']).to eq(due_date) @@ -868,7 +868,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues", user), title: 'new issue', labels: 'label, label2', created_at: creation_time - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) end end @@ -899,7 +899,7 @@ describe API::V3::Issues, :mailer do it "does not create a new project issue" do expect { post v3_api("/projects/#{project.id}/issues", user), params }.not_to change(Issue, :count) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) spam_logs = SpamLog.all @@ -917,7 +917,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -925,7 +925,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/44444", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'allows special label names' do @@ -946,21 +946,21 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", non_member), title: 'updated title' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "returns 403 for project members with guest role" do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", guest), title: 'updated title' - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "updates a confidential issue for project members" do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -968,7 +968,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", author), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -976,7 +976,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", admin), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -984,7 +984,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), confidential: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_truthy end @@ -992,7 +992,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", user), confidential: false - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['confidential']).to be_falsy end @@ -1000,7 +1000,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}", user), confidential: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('confidential is invalid') end end @@ -1021,7 +1021,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) spam_logs = SpamLog.all @@ -1041,7 +1041,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([label.title]) end @@ -1060,7 +1060,7 @@ describe API::V3::Issues, :mailer do it 'removes all labels' do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), labels: '' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to eq([]) end @@ -1068,7 +1068,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), labels: 'foo,bar' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'foo' expect(json_response['labels']).to include 'bar' end @@ -1092,7 +1092,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), title: 'g' * 256 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['title']).to eq([ 'is too long (maximum is 255 characters)' ]) @@ -1104,7 +1104,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), labels: 'label2', state_event: "close" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label2' expect(json_response['state']).to eq "closed" end @@ -1112,7 +1112,7 @@ describe API::V3::Issues, :mailer do it 'reopens a project isssue' do put v3_api("/projects/#{project.id}/issues/#{closed_issue.id}", user), state_event: 'reopen' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq 'opened' end @@ -1122,7 +1122,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), labels: 'label3', state_event: 'close', updated_at: update_time - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['labels']).to include 'label3' expect(Time.parse(json_response['updated_at'])).to be_like_time(update_time) end @@ -1135,7 +1135,7 @@ describe API::V3::Issues, :mailer do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), due_date: due_date - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['due_date']).to eq(due_date) end end @@ -1144,14 +1144,14 @@ describe API::V3::Issues, :mailer do it 'updates an issue with no assignee' do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), assignee_id: 0 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignee']).to eq(nil) end it 'updates an issue with assignee' do put v3_api("/projects/#{project.id}/issues/#{issue.id}", user), assignee_id: user2.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['assignee']['name']).to eq(user2.name) end end @@ -1160,13 +1160,13 @@ describe API::V3::Issues, :mailer do it "rejects a non member from deleting an issue" do delete v3_api("/projects/#{project.id}/issues/#{issue.id}", non_member) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it "rejects a developer from deleting an issue" do delete v3_api("/projects/#{project.id}/issues/#{issue.id}", author) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end context "when the user is project owner" do @@ -1176,7 +1176,7 @@ describe API::V3::Issues, :mailer do it "deletes the issue if an admin requests it" do delete v3_api("/projects/#{project.id}/issues/#{issue.id}", owner) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq 'opened' end end @@ -1185,7 +1185,7 @@ describe API::V3::Issues, :mailer do it 'returns 404 when trying to move an issue' do delete v3_api("/projects/#{project.id}/issues/123", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1198,7 +1198,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project.id) end @@ -1207,7 +1207,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: project.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue to project it originates from!') end end @@ -1217,7 +1217,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: target_project2.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!') end end @@ -1226,7 +1226,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", admin), to_project_id: target_project2.id - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['project_id']).to eq(target_project2.id) end @@ -1235,7 +1235,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/123/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Issue Not Found') end end @@ -1245,7 +1245,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/123/issues/#{issue.id}/move", user), to_project_id: target_project.id - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end end @@ -1255,7 +1255,7 @@ describe API::V3::Issues, :mailer do post v3_api("/projects/#{project.id}/issues/#{issue.id}/move", user), to_project_id: 123 - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1264,26 +1264,26 @@ describe API::V3::Issues, :mailer do it 'subscribes to an issue' do post v3_api("/projects/#{project.id}/issues/#{issue.id}/subscription", user2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['subscribed']).to eq(true) end it 'returns 304 if already subscribed' do post v3_api("/projects/#{project.id}/issues/#{issue.id}/subscription", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the issue is not found' do post v3_api("/projects/#{project.id}/issues/123/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue is confidential' do post v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}/subscription", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1291,26 +1291,26 @@ describe API::V3::Issues, :mailer do it 'unsubscribes from an issue' do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/subscription", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['subscribed']).to eq(false) end it 'returns 304 if not subscribed' do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/subscription", user2) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the issue is not found' do delete v3_api("/projects/#{project.id}/issues/123/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 404 if the issue is confidential' do delete v3_api("/projects/#{project.id}/issues/#{confidential_issue.id}/subscription", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/requests/api/v3/labels_spec.rb b/spec/requests/api/v3/labels_spec.rb index 32f37a08024..1d31213d5ca 100644 --- a/spec/requests/api/v3/labels_spec.rb +++ b/spec/requests/api/v3/labels_spec.rb @@ -27,7 +27,7 @@ describe API::V3::Labels do get v3_api("/projects/#{project.id}/labels", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(3) expect(json_response.first.keys).to match_array expected_keys @@ -71,7 +71,7 @@ describe API::V3::Labels do it "subscribes to the label" do post v3_api("/projects/#{project.id}/labels/#{label1.title}/subscription", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_truthy end @@ -81,7 +81,7 @@ describe API::V3::Labels do it "subscribes to the label" do post v3_api("/projects/#{project.id}/labels/#{label1.id}/subscription", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_truthy end @@ -93,7 +93,7 @@ describe API::V3::Labels do it "returns 304" do post v3_api("/projects/#{project.id}/labels/#{label1.id}/subscription", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end @@ -101,7 +101,7 @@ describe API::V3::Labels do it "returns 404 error" do post v3_api("/projects/#{project.id}/labels/1234/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -113,7 +113,7 @@ describe API::V3::Labels do it "unsubscribes from the label" do delete v3_api("/projects/#{project.id}/labels/#{label1.title}/subscription", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_falsey end @@ -123,7 +123,7 @@ describe API::V3::Labels do it "unsubscribes from the label" do delete v3_api("/projects/#{project.id}/labels/#{label1.id}/subscription", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["name"]).to eq(label1.title) expect(json_response["subscribed"]).to be_falsey end @@ -135,7 +135,7 @@ describe API::V3::Labels do it "returns 304" do delete v3_api("/projects/#{project.id}/labels/#{label1.id}/subscription", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end @@ -143,7 +143,7 @@ describe API::V3::Labels do it "returns 404 error" do delete v3_api("/projects/#{project.id}/labels/1234/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -152,18 +152,18 @@ describe API::V3::Labels do it 'returns 200 for existing label' do delete v3_api("/projects/#{project.id}/labels", user), name: 'label1' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns 404 for non existing label' do delete v3_api("/projects/#{project.id}/labels", user), name: 'label2' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Label Not Found') end it 'returns 400 for wrong parameters' do delete v3_api("/projects/#{project.id}/labels", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end end diff --git a/spec/requests/api/v3/members_spec.rb b/spec/requests/api/v3/members_spec.rb index bc918a8eb02..68be3d24c26 100644 --- a/spec/requests/api/v3/members_spec.rb +++ b/spec/requests/api/v3/members_spec.rb @@ -34,7 +34,7 @@ describe API::V3::Members do user = public_send(type) get v3_api("/#{source_type.pluralize}/#{source.id}/members", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) expect(json_response.map { |u| u['id'] }).to match_array [master.id, developer.id] end @@ -46,7 +46,7 @@ describe API::V3::Members do get v3_api("/#{source_type.pluralize}/#{source.id}/members", developer) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) expect(json_response.map { |u| u['id'] }).to match_array [master.id, developer.id] end @@ -54,7 +54,7 @@ describe API::V3::Members do it 'finds members with query string' do get v3_api("/#{source_type.pluralize}/#{source.id}/members", developer), query: master.username - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.count).to eq(1) expect(json_response.first['username']).to eq(master.username) end @@ -74,7 +74,7 @@ describe API::V3::Members do user = public_send(type) get v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # User attributes expect(json_response['id']).to eq(developer.id) expect(json_response['name']).to eq(developer.name) @@ -109,7 +109,7 @@ describe API::V3::Members do post v3_api("/#{source_type.pluralize}/#{source.id}/members", user), user_id: access_requester.id, access_level: Member::MASTER - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -122,7 +122,7 @@ describe API::V3::Members do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: access_requester.id, access_level: Member::MASTER - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) expect(source.requesters.count).to eq(0) expect(json_response['id']).to eq(access_requester.id) @@ -135,7 +135,7 @@ describe API::V3::Members do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id, access_level: Member::DEVELOPER, expires_at: '2016-08-05' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end.to change { source.members.count }.by(1) expect(json_response['id']).to eq(stranger.id) expect(json_response['access_level']).to eq(Member::DEVELOPER) @@ -147,28 +147,28 @@ describe API::V3::Members do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: master.id, access_level: Member::MASTER - expect(response).to have_http_status(source_type == 'project' ? 201 : 409) + expect(response).to have_gitlab_http_status(source_type == 'project' ? 201 : 409) end it 'returns 400 when user_id is not given' do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), access_level: Member::MASTER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 400 when access_level is not given' do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 422 when access_level is not valid' do post v3_api("/#{source_type.pluralize}/#{source.id}/members", master), user_id: stranger.id, access_level: 1234 - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end end @@ -190,7 +190,7 @@ describe API::V3::Members do put v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user), access_level: Member::MASTER - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -201,7 +201,7 @@ describe API::V3::Members do put v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master), access_level: Member::MASTER, expires_at: '2016-08-05' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(developer.id) expect(json_response['access_level']).to eq(Member::MASTER) expect(json_response['expires_at']).to eq('2016-08-05') @@ -212,20 +212,20 @@ describe API::V3::Members do put v3_api("/#{source_type.pluralize}/#{source.id}/members/123", master), access_level: Member::MASTER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 400 when access_level is not given' do put v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns 422 when access level is not valid' do put v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master), access_level: 1234 - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end end @@ -243,7 +243,7 @@ describe API::V3::Members do user = public_send(type) delete v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -254,7 +254,7 @@ describe API::V3::Members do expect do delete v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", developer) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { source.members.count }.by(-1) end end @@ -265,7 +265,7 @@ describe API::V3::Members do expect do delete v3_api("/#{source_type.pluralize}/#{source.id}/members/#{access_requester.id}", master) - expect(response).to have_http_status(source_type == 'project' ? 200 : 404) + expect(response).to have_gitlab_http_status(source_type == 'project' ? 200 : 404) end.not_to change { source.requesters.count } end end @@ -274,7 +274,7 @@ describe API::V3::Members do expect do delete v3_api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", master) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { source.members.count }.by(-1) end end @@ -282,7 +282,7 @@ describe API::V3::Members do it "returns #{source_type == 'project' ? 200 : 404} if member does not exist" do delete v3_api("/#{source_type.pluralize}/#{source.id}/members/123", master) - expect(response).to have_http_status(source_type == 'project' ? 200 : 404) + expect(response).to have_gitlab_http_status(source_type == 'project' ? 200 : 404) end end end @@ -333,7 +333,7 @@ describe API::V3::Members do post v3_api("/projects/#{project.id}/members", master), user_id: stranger.id, access_level: Member::OWNER - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end.to change { project.members.count }.by(0) end end diff --git a/spec/requests/api/v3/merge_request_diffs_spec.rb b/spec/requests/api/v3/merge_request_diffs_spec.rb index 3f21ff40726..e613036a88d 100644 --- a/spec/requests/api/v3/merge_request_diffs_spec.rb +++ b/spec/requests/api/v3/merge_request_diffs_spec.rb @@ -24,7 +24,7 @@ describe API::V3::MergeRequestDiffs, 'MergeRequestDiffs' do it 'returns a 404 when merge_request_id not found' do get v3_api("/projects/#{project.id}/merge_requests/999/versions", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -42,7 +42,7 @@ describe API::V3::MergeRequestDiffs, 'MergeRequestDiffs' do it 'returns a 404 when merge_request_id not found' do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions/999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/merge_requests_spec.rb b/spec/requests/api/v3/merge_requests_spec.rb index df73c731c96..26251b95680 100644 --- a/spec/requests/api/v3/merge_requests_spec.rb +++ b/spec/requests/api/v3/merge_requests_spec.rb @@ -21,14 +21,14 @@ describe API::MergeRequests do context "when unauthenticated" do it "returns authentication error" do get v3_api("/projects/#{project.id}/merge_requests") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context "when authenticated" do it "returns an array of all merge_requests" do get v3_api("/projects/#{project.id}/merge_requests", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) expect(json_response.last['title']).to eq(merge_request.title) @@ -44,7 +44,7 @@ describe API::MergeRequests do it "returns an array of all merge_requests" do get v3_api("/projects/#{project.id}/merge_requests?state", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) expect(json_response.last['title']).to eq(merge_request.title) @@ -52,7 +52,7 @@ describe API::MergeRequests do it "returns an array of open merge_requests" do get v3_api("/projects/#{project.id}/merge_requests?state=opened", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.last['title']).to eq(merge_request.title) @@ -60,7 +60,7 @@ describe API::MergeRequests do it "returns an array of closed merge_requests" do get v3_api("/projects/#{project.id}/merge_requests?state=closed", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['title']).to eq(merge_request_closed.title) @@ -68,7 +68,7 @@ describe API::MergeRequests do it "returns an array of merged merge_requests" do get v3_api("/projects/#{project.id}/merge_requests?state=merged", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['title']).to eq(merge_request_merged.title) @@ -77,7 +77,7 @@ describe API::MergeRequests do it 'matches V3 response schema' do get v3_api("/projects/#{project.id}/merge_requests", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v3/merge_requests') end @@ -89,7 +89,7 @@ describe API::MergeRequests do it "returns an array of merge_requests in ascending order" do get v3_api("/projects/#{project.id}/merge_requests?sort=asc", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) response_dates = json_response.map { |merge_request| merge_request['created_at'] } @@ -98,7 +98,7 @@ describe API::MergeRequests do it "returns an array of merge_requests in descending order" do get v3_api("/projects/#{project.id}/merge_requests?sort=desc", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) response_dates = json_response.map { |merge_request| merge_request['created_at'] } @@ -107,7 +107,7 @@ describe API::MergeRequests do it "returns an array of merge_requests ordered by updated_at" do get v3_api("/projects/#{project.id}/merge_requests?order_by=updated_at", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) response_dates = json_response.map { |merge_request| merge_request['updated_at'] } @@ -116,7 +116,7 @@ describe API::MergeRequests do it "returns an array of merge_requests ordered by created_at" do get v3_api("/projects/#{project.id}/merge_requests?order_by=created_at&sort=asc", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(3) response_dates = json_response.map { |merge_request| merge_request['created_at'] } @@ -130,7 +130,7 @@ describe API::MergeRequests do it 'exposes known attributes' do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(merge_request.id) expect(json_response['iid']).to eq(merge_request.iid) expect(json_response['project_id']).to eq(merge_request.project.id) @@ -158,7 +158,7 @@ describe API::MergeRequests do it "returns merge_request" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(merge_request.title) expect(json_response['iid']).to eq(merge_request.iid) expect(json_response['work_in_progress']).to eq(false) @@ -178,7 +178,7 @@ describe API::MergeRequests do it 'returns merge_request by iid array' do get v3_api("/projects/#{project.id}/merge_requests", user), iid: [merge_request.iid, merge_request_closed.iid] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['title']).to eq merge_request_closed.title @@ -187,7 +187,7 @@ describe API::MergeRequests do it "returns a 404 error if merge_request_id not found" do get v3_api("/projects/#{project.id}/merge_requests/999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'Work in Progress' do @@ -195,7 +195,7 @@ describe API::MergeRequests do it "returns merge_request" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request_wip.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['work_in_progress']).to eq(true) end end @@ -214,7 +214,7 @@ describe API::MergeRequests do it 'returns a 404 when merge_request_id not found' do get v3_api("/projects/#{project.id}/merge_requests/999/commits", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -227,7 +227,7 @@ describe API::MergeRequests do it 'returns a 404 when merge_request_id not found' do get v3_api("/projects/#{project.id}/merge_requests/999/changes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -243,7 +243,7 @@ describe API::MergeRequests do milestone_id: milestone.id, remove_source_branch: true - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('Test merge_request') expect(json_response['labels']).to eq(%w(label label2)) expect(json_response['milestone']['id']).to eq(milestone.id) @@ -253,25 +253,25 @@ describe API::MergeRequests do it "returns 422 when source_branch equals target_branch" do post v3_api("/projects/#{project.id}/merge_requests", user), title: "Test merge_request", source_branch: "master", target_branch: "master", author: user - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end it "returns 400 when source_branch is missing" do post v3_api("/projects/#{project.id}/merge_requests", user), title: "Test merge_request", target_branch: "master", author: user - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 when target_branch is missing" do post v3_api("/projects/#{project.id}/merge_requests", user), title: "Test merge_request", source_branch: "markdown", author: user - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 400 when title is missing" do post v3_api("/projects/#{project.id}/merge_requests", user), target_branch: 'master', source_branch: 'markdown' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'allows special label names' do @@ -307,7 +307,7 @@ describe API::MergeRequests do target_branch: 'master', author: user end.to change { MergeRequest.count }.by(0) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) end end end @@ -403,7 +403,7 @@ describe API::MergeRequests do it "denies the deletion of the merge request" do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", developer) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -411,7 +411,7 @@ describe API::MergeRequests do it "destroys the merge request owners can destroy" do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -422,7 +422,7 @@ describe API::MergeRequests do it "returns merge_request in case of success" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns 406 if branch can't be merged" do @@ -431,21 +431,21 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(406) + expect(response).to have_gitlab_http_status(406) expect(json_response['message']).to eq('Branch cannot be merged') end it "returns 405 if merge_request is not open" do merge_request.close put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(405) + expect(response).to have_gitlab_http_status(405) expect(json_response['message']).to eq('405 Method Not Allowed') end it "returns 405 if merge_request is a work in progress" do merge_request.update_attribute(:title, "WIP: #{merge_request.title}") put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(405) + expect(response).to have_gitlab_http_status(405) expect(json_response['message']).to eq('405 Method Not Allowed') end @@ -454,7 +454,7 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user) - expect(response).to have_http_status(405) + expect(response).to have_gitlab_http_status(405) expect(json_response['message']).to eq('405 Method Not Allowed') end @@ -462,21 +462,21 @@ describe API::MergeRequests do user2 = create(:user) project.team << [user2, :reporter] put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user2) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(json_response['message']).to eq('401 Unauthorized') end it "returns 409 if the SHA parameter doesn't match" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), sha: merge_request.diff_head_sha.reverse - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) expect(json_response['message']).to start_with('SHA does not match HEAD of source branch') end it "succeeds if the SHA parameter matches" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), sha: merge_request.diff_head_sha - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "enables merge when pipeline succeeds if the pipeline is active" do @@ -485,7 +485,7 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/merge", user), merge_when_build_succeeds: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('Test') expect(json_response['merge_when_build_succeeds']).to eq(true) end @@ -496,39 +496,39 @@ describe API::MergeRequests do it "returns merge_request" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: "close" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq('closed') end end it "updates title and returns merge_request" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), title: "New title" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('New title') end it "updates description and returns merge_request" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), description: "New description" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['description']).to eq('New description') end it "updates milestone_id and returns merge_request" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), milestone_id: milestone.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['milestone']['id']).to eq(milestone.id) end it "returns merge_request with renamed target_branch" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), target_branch: "wiki" - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['target_branch']).to eq('wiki') end it "returns merge_request that removes the source branch" do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), remove_source_branch: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['force_remove_source_branch']).to be_truthy end @@ -549,7 +549,7 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: 'close', title: nil merge_request.reload - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(merge_request.state).to eq('opened') end @@ -557,7 +557,7 @@ describe API::MergeRequests do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), state_event: 'close', target_branch: nil merge_request.reload - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(merge_request.state).to eq('opened') end end @@ -568,7 +568,7 @@ describe API::MergeRequests do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user), note: "My comment" - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['note']).to eq('My comment') expect(json_response['author']['name']).to eq(user.name) expect(json_response['author']['username']).to eq(user.username) @@ -577,13 +577,13 @@ describe API::MergeRequests do it "returns 400 if note is missing" do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns 404 if note is attached to non existent merge request" do post v3_api("/projects/#{project.id}/merge_requests/404/comments", user), note: 'My comment' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -593,7 +593,7 @@ describe API::MergeRequests do it "returns merge_request comments ordered by created_at" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/comments", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.first['note']).to eq("a comment on a MR") @@ -603,7 +603,7 @@ describe API::MergeRequests do it "returns a 404 error if merge_request_id not found" do get v3_api("/projects/#{project.id}/merge_requests/999/comments", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -615,7 +615,7 @@ describe API::MergeRequests do end get v3_api("/projects/#{project.id}/merge_requests/#{mr.id}/closes_issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(issue.id) @@ -623,7 +623,7 @@ describe API::MergeRequests do it 'returns an empty array when there are no issues to be closed' do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/closes_issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -636,7 +636,7 @@ describe API::MergeRequests do get v3_api("/projects/#{jira_project.id}/merge_requests/#{merge_request.id}/closes_issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['title']).to eq(issue.title) @@ -651,7 +651,7 @@ describe API::MergeRequests do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/closes_issues", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -659,20 +659,20 @@ describe API::MergeRequests do it 'subscribes to a merge request' do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['subscribed']).to eq(true) end it 'returns 304 if already subscribed' do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", user) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the merge request is not found' do post v3_api("/projects/#{project.id}/merge_requests/123/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 403 if user has no access to read code' do @@ -681,7 +681,7 @@ describe API::MergeRequests do post v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -689,20 +689,20 @@ describe API::MergeRequests do it 'unsubscribes from a merge request' do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['subscribed']).to eq(false) end it 'returns 304 if not subscribed' do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", admin) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end it 'returns 404 if the merge request is not found' do post v3_api("/projects/#{project.id}/merge_requests/123/subscription", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns 403 if user has no access to read code' do @@ -711,7 +711,7 @@ describe API::MergeRequests do delete v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscription", guest) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end diff --git a/spec/requests/api/v3/milestones_spec.rb b/spec/requests/api/v3/milestones_spec.rb index feaa87faec7..e82f35598a6 100644 --- a/spec/requests/api/v3/milestones_spec.rb +++ b/spec/requests/api/v3/milestones_spec.rb @@ -12,7 +12,7 @@ describe API::V3::Milestones do it 'returns project milestones' do get v3_api("/projects/#{project.id}/milestones", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['title']).to eq(milestone.title) end @@ -20,13 +20,13 @@ describe API::V3::Milestones do it 'returns a 401 error if user not authenticated' do get v3_api("/projects/#{project.id}/milestones") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns an array of active milestones' do get v3_api("/projects/#{project.id}/milestones?state=active", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(milestone.id) @@ -35,7 +35,7 @@ describe API::V3::Milestones do it 'returns an array of closed milestones' do get v3_api("/projects/#{project.id}/milestones?state=closed", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(closed_milestone.id) @@ -46,7 +46,7 @@ describe API::V3::Milestones do it 'returns a project milestone by id' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(milestone.title) expect(json_response['iid']).to eq(milestone.iid) end @@ -63,7 +63,7 @@ describe API::V3::Milestones do it 'returns a project milestone by iid array' do get v3_api("/projects/#{project.id}/milestones", user), iid: [milestone.iid, closed_milestone.iid] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) expect(json_response.first['title']).to eq milestone.title expect(json_response.first['id']).to eq milestone.id @@ -72,13 +72,13 @@ describe API::V3::Milestones do it 'returns 401 error if user not authenticated' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 404 error if milestone id not found' do get v3_api("/projects/#{project.id}/milestones/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -86,7 +86,7 @@ describe API::V3::Milestones do it 'creates a new project milestone' do post v3_api("/projects/#{project.id}/milestones", user), title: 'new milestone' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new milestone') expect(json_response['description']).to be_nil end @@ -95,7 +95,7 @@ describe API::V3::Milestones do post v3_api("/projects/#{project.id}/milestones", user), title: 'new milestone', description: 'release', due_date: '2013-03-02', start_date: '2013-02-02' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['description']).to eq('release') expect(json_response['due_date']).to eq('2013-03-02') expect(json_response['start_date']).to eq('2013-02-02') @@ -104,20 +104,20 @@ describe API::V3::Milestones do it 'returns a 400 error if title is missing' do post v3_api("/projects/#{project.id}/milestones", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 error if params are invalid (duplicate title)' do post v3_api("/projects/#{project.id}/milestones", user), title: milestone.title, description: 'release', due_date: '2013-03-02' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'creates a new project with reserved html characters' do post v3_api("/projects/#{project.id}/milestones", user), title: 'foo & bar 1.1 -> 2.2' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('foo & bar 1.1 -> 2.2') expect(json_response['description']).to be_nil end @@ -128,7 +128,7 @@ describe API::V3::Milestones do put v3_api("/projects/#{project.id}/milestones/#{milestone.id}", user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -137,7 +137,7 @@ describe API::V3::Milestones do put v3_api("/projects/#{project.id}/milestones/#{milestone.id}", user), due_date: nil - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['due_date']).to be_nil end @@ -145,7 +145,7 @@ describe API::V3::Milestones do put v3_api("/projects/#{project.id}/milestones/1234", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -153,7 +153,7 @@ describe API::V3::Milestones do it 'updates a project milestone' do put v3_api("/projects/#{project.id}/milestones/#{milestone.id}", user), state_event: 'close' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq('closed') end @@ -175,7 +175,7 @@ describe API::V3::Milestones do it 'returns project issues for a particular milestone' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['milestone']['title']).to eq(milestone.title) end @@ -183,14 +183,14 @@ describe API::V3::Milestones do it 'matches V3 response schema for a list of issues' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}/issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v3/issues') end it 'returns a 401 error if user not authenticated' do get v3_api("/projects/#{project.id}/milestones/#{milestone.id}/issues") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end describe 'confidential issues' do @@ -207,7 +207,7 @@ describe API::V3::Milestones do it 'returns confidential issues to team members' do get v3_api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(2) expect(json_response.map { |issue| issue['id'] }).to include(issue.id, confidential_issue.id) @@ -219,7 +219,7 @@ describe API::V3::Milestones do get v3_api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", member) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) expect(json_response.map { |issue| issue['id'] }).to include(issue.id) @@ -228,7 +228,7 @@ describe API::V3::Milestones do it 'does not return confidential issues to regular users' do get v3_api("/projects/#{public_project.id}/milestones/#{milestone.id}/issues", create(:user)) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) expect(json_response.map { |issue| issue['id'] }).to include(issue.id) diff --git a/spec/requests/api/v3/notes_spec.rb b/spec/requests/api/v3/notes_spec.rb index 56729692eed..d3455a4bba4 100644 --- a/spec/requests/api/v3/notes_spec.rb +++ b/spec/requests/api/v3/notes_spec.rb @@ -35,7 +35,7 @@ describe API::V3::Notes do it "returns an array of issue notes" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(issue_note.note) @@ -46,14 +46,14 @@ describe API::V3::Notes do it "returns a 404 error when issue id not found" do get v3_api("/projects/#{project.id}/issues/12345/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "and current user cannot view the notes" do it "returns an empty array" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response).to be_empty @@ -65,7 +65,7 @@ describe API::V3::Notes do it "returns 404" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -73,7 +73,7 @@ describe API::V3::Notes do it "returns an empty array" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes", private_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(cross_reference_note.note) @@ -86,7 +86,7 @@ describe API::V3::Notes do it "returns an array of snippet notes" do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(snippet_note.note) @@ -95,13 +95,13 @@ describe API::V3::Notes do it "returns a 404 error when snippet id not found" do get v3_api("/projects/#{project.id}/snippets/42/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 when not authorized" do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -109,7 +109,7 @@ describe API::V3::Notes do it "returns an array of merge_requests notes" do get v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/notes", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['body']).to eq(merge_request_note.note) @@ -118,13 +118,13 @@ describe API::V3::Notes do it "returns a 404 error if merge request id not found" do get v3_api("/projects/#{project.id}/merge_requests/4444/notes", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 404 when not authorized" do get v3_api("/projects/#{project.id}/merge_requests/4444/notes", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -134,21 +134,21 @@ describe API::V3::Notes do it "returns an issue note by id" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{issue_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(issue_note.note) end it "returns a 404 error if issue note not found" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "and current user cannot view the note" do it "returns a 404 error" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes/#{cross_reference_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context "when issue is confidential" do @@ -157,7 +157,7 @@ describe API::V3::Notes do it "returns 404" do get v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/#{issue_note.id}", private_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -165,7 +165,7 @@ describe API::V3::Notes do it "returns an issue note by id" do get v3_api("/projects/#{ext_proj.id}/issues/#{ext_issue.id}/notes/#{cross_reference_note.id}", private_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(cross_reference_note.note) end end @@ -176,14 +176,14 @@ describe API::V3::Notes do it "returns a snippet note by id" do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes/#{snippet_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq(snippet_note.note) end it "returns a 404 error if snippet note not found" do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -193,7 +193,7 @@ describe API::V3::Notes do it "creates a new issue note" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -201,13 +201,13 @@ describe API::V3::Notes do it "returns a 400 bad request error if body not given" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if user not authenticated" do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes"), body: 'hi!' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end context 'when an admin or owner makes the request' do @@ -216,7 +216,7 @@ describe API::V3::Notes do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'hi!', created_at: creation_time - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) @@ -229,7 +229,7 @@ describe API::V3::Notes do it 'creates a new issue note' do post v3_api("/projects/#{project.id}/issues/#{issue2.id}/notes", user), body: ':+1:' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq(':+1:') end end @@ -238,7 +238,7 @@ describe API::V3::Notes do it 'creates a new issue note' do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: ':+1:' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq(':+1:') end end @@ -248,7 +248,7 @@ describe API::V3::Notes do it "creates a new snippet note" do post v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user), body: 'hi!' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['body']).to eq('hi!') expect(json_response['author']['username']).to eq(user.username) end @@ -256,13 +256,13 @@ describe API::V3::Notes do it "returns a 400 bad request error if body not given" do post v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 401 unauthorized error if user not authenticated" do post v3_api("/projects/#{project.id}/snippets/#{snippet.id}/notes"), body: 'hi!' - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -274,7 +274,7 @@ describe API::V3::Notes do post v3_api("/projects/#{project.id}/issues/#{issue.id}/notes", user), body: 'Foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -314,7 +314,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/issues/#{issue.id}/"\ "notes/#{issue_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -322,14 +322,14 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user), body: 'Hello!' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 400 bad request error if body not given' do put v3_api("/projects/#{project.id}/issues/#{issue.id}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -338,7 +338,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -346,7 +346,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/12345", user), body: "Hello!" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -355,7 +355,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\ "notes/#{merge_request_note.id}", user), body: 'Hello!' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['body']).to eq('Hello!') end @@ -363,7 +363,7 @@ describe API::V3::Notes do put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\ "notes/12345", user), body: "Hello!" - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -374,17 +374,17 @@ describe API::V3::Notes do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # Check if note is really deleted delete v3_api("/projects/#{project.id}/issues/#{issue.id}/"\ "notes/#{issue_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -393,18 +393,18 @@ describe API::V3::Notes do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # Check if note is really deleted delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/#{snippet_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\ "notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -413,18 +413,18 @@ describe API::V3::Notes do delete v3_api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.id}/notes/#{merge_request_note.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) # Check if note is really deleted delete v3_api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.id}/notes/#{merge_request_note.id}", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when note id not found' do delete v3_api("/projects/#{project.id}/merge_requests/"\ "#{merge_request.id}/notes/12345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/pipelines_spec.rb b/spec/requests/api/v3/pipelines_spec.rb index e1d036ff365..1c7d9fe32bb 100644 --- a/spec/requests/api/v3/pipelines_spec.rb +++ b/spec/requests/api/v3/pipelines_spec.rb @@ -32,7 +32,7 @@ describe API::V3::Pipelines do it 'returns project pipelines' do get v3_api("/projects/#{project.id}/pipelines", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['sha']).to match(/\A\h{40}\z/) expect(json_response.first['id']).to eq pipeline.id @@ -44,7 +44,7 @@ describe API::V3::Pipelines do it 'does not return project pipelines' do get v3_api("/projects/#{project.id}/pipelines", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -61,7 +61,7 @@ describe API::V3::Pipelines do post v3_api("/projects/#{project.id}/pipeline", user), ref: project.default_branch end.to change { Ci::Pipeline.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to be_a Hash expect(json_response['sha']).to eq project.commit.id end @@ -69,7 +69,7 @@ describe API::V3::Pipelines do it 'fails when using an invalid ref' do post v3_api("/projects/#{project.id}/pipeline", user), ref: 'invalid_ref' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Reference not found' expect(json_response).not_to be_an Array end @@ -79,7 +79,7 @@ describe API::V3::Pipelines do it 'fails to create pipeline' do post v3_api("/projects/#{project.id}/pipeline", user), ref: project.default_branch - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base'].first).to eq 'Missing .gitlab-ci.yml file' expect(json_response).not_to be_an Array end @@ -90,7 +90,7 @@ describe API::V3::Pipelines do it 'does not create pipeline' do post v3_api("/projects/#{project.id}/pipeline", non_member), ref: project.default_branch - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response).not_to be_an Array end @@ -102,14 +102,14 @@ describe API::V3::Pipelines do it 'returns project pipelines' do get v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['sha']).to match /\A\h{40}\z/ end it 'returns 404 when it does not exist' do get v3_api("/projects/#{project.id}/pipelines/123456", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Not found' expect(json_response['id']).to be nil end @@ -131,7 +131,7 @@ describe API::V3::Pipelines do it 'should not return a project pipeline' do get v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -152,7 +152,7 @@ describe API::V3::Pipelines do post v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user) end.to change { pipeline.builds.count }.from(1).to(2) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(build.reload.retried?).to be true end end @@ -161,7 +161,7 @@ describe API::V3::Pipelines do it 'should not return a project pipeline' do post v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", non_member) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq '404 Project Not Found' expect(json_response['id']).to be nil end @@ -180,7 +180,7 @@ describe API::V3::Pipelines do it 'retries failed builds' do post v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['status']).to eq('canceled') end end @@ -193,7 +193,7 @@ describe API::V3::Pipelines do it 'rejects the action' do post v3_api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", reporter) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(pipeline.reload.status).to eq('pending') end end diff --git a/spec/requests/api/v3/project_hooks_spec.rb b/spec/requests/api/v3/project_hooks_spec.rb index b0eddbb5dd2..00f59744a31 100644 --- a/spec/requests/api/v3/project_hooks_spec.rb +++ b/spec/requests/api/v3/project_hooks_spec.rb @@ -22,7 +22,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns project hooks" do get v3_api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.count).to eq(1) expect(json_response.first['url']).to eq("http://example.com") @@ -42,7 +42,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "does not access project hooks" do get v3_api("/projects/#{project.id}/hooks", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -51,7 +51,7 @@ describe API::ProjectHooks, 'ProjectHooks' do context "authorized user" do it "returns a project hook" do get v3_api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq(hook.url) expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['push_events']).to eq(hook.push_events) @@ -66,20 +66,20 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 404 error if hook id is not available" do get v3_api("/projects/#{project.id}/hooks/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context "unauthorized user" do it "does not access an existing hook" do get v3_api("/projects/#{project.id}/hooks/#{hook.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it "returns a 404 error if hook id is not available" do get v3_api("/projects/#{project.id}/hooks/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -90,7 +90,7 @@ describe API::ProjectHooks, 'ProjectHooks' do url: "http://example.com", issues_events: true, wiki_page_events: true, build_events: true end.to change {project.hooks.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['url']).to eq('http://example.com') expect(json_response['issues_events']).to eq(true) expect(json_response['push_events']).to eq(true) @@ -111,7 +111,7 @@ describe API::ProjectHooks, 'ProjectHooks' do post v3_api("/projects/#{project.id}/hooks", user), url: "http://example.com", token: token end.to change {project.hooks.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response["url"]).to eq("http://example.com") expect(json_response).not_to include("token") @@ -123,12 +123,12 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns a 400 error if url not given" do post v3_api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 422 error if url not valid" do post v3_api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com" - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -136,7 +136,7 @@ describe API::ProjectHooks, 'ProjectHooks' do it "updates an existing project hook" do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'http://example.org', push_events: false, build_events: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['url']).to eq('http://example.org') expect(json_response['issues_events']).to eq(hook.issues_events) expect(json_response['push_events']).to eq(false) @@ -154,7 +154,7 @@ describe API::ProjectHooks, 'ProjectHooks' do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), url: "http://example.org", token: token - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response["url"]).to eq("http://example.org") expect(json_response).not_to include("token") @@ -164,17 +164,17 @@ describe API::ProjectHooks, 'ProjectHooks' do it "returns 404 error if hook id not found" do put v3_api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns 400 error if url is not given" do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 422 error if url is not valid" do put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com' - expect(response).to have_http_status(422) + expect(response).to have_gitlab_http_status(422) end end @@ -183,23 +183,23 @@ describe API::ProjectHooks, 'ProjectHooks' do expect do delete v3_api("/projects/#{project.id}/hooks/#{hook.id}", user) end.to change {project.hooks.count}.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns success when deleting hook" do delete v3_api("/projects/#{project.id}/hooks/#{hook.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it "returns a 404 error when deleting non existent hook" do delete v3_api("/projects/#{project.id}/hooks/42", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 404 error if hook id not given" do delete v3_api("/projects/#{project.id}/hooks", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 404 if a user attempts to delete project hooks he/she does not own" do @@ -208,7 +208,7 @@ describe API::ProjectHooks, 'ProjectHooks' do other_project.team << [test_user, :master] delete v3_api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(WebHook.exists?(hook.id)).to be_truthy end end diff --git a/spec/requests/api/v3/project_snippets_spec.rb b/spec/requests/api/v3/project_snippets_spec.rb index 7e88489082a..2ed31b99516 100644 --- a/spec/requests/api/v3/project_snippets_spec.rb +++ b/spec/requests/api/v3/project_snippets_spec.rb @@ -28,7 +28,7 @@ describe API::ProjectSnippets do get v3_api("/projects/#{project.id}/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(3) expect(json_response.map { |snippet| snippet['id']} ).to include(public_snippet.id, internal_snippet.id, private_snippet.id) expect(json_response.last).to have_key('web_url') @@ -38,7 +38,7 @@ describe API::ProjectSnippets do create(:project_snippet, :private, project: project) get v3_api("/projects/#{project.id}/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(0) end end @@ -56,7 +56,7 @@ describe API::ProjectSnippets do it 'creates a new snippet' do post v3_api("/projects/#{project.id}/snippets/", admin), params - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) snippet = ProjectSnippet.find(json_response['id']) expect(snippet.content).to eq(params[:code]) expect(snippet.title).to eq(params[:title]) @@ -69,7 +69,7 @@ describe API::ProjectSnippets do post v3_api("/projects/#{project.id}/snippets/", admin), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -95,7 +95,7 @@ describe API::ProjectSnippets do expect { create_snippet(project, visibility_level: Snippet::PUBLIC) } .not_to change { Snippet.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -116,7 +116,7 @@ describe API::ProjectSnippets do put v3_api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), code: new_content - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) snippet.reload expect(snippet.content).to eq(new_content) end @@ -124,14 +124,14 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do put v3_api("/projects/#{snippet.project.id}/snippets/1234", admin), title: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put v3_api("/projects/#{project.id}/snippets/1234", admin) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -173,7 +173,7 @@ describe API::ProjectSnippets do expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) } .not_to change { snippet.reload.title } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq({ "error" => "Spam detected" }) end @@ -194,13 +194,13 @@ describe API::ProjectSnippets do delete v3_api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns 404 for invalid snippet id' do delete v3_api("/projects/#{snippet.project.id}/snippets/1234", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end @@ -211,7 +211,7 @@ describe API::ProjectSnippets do it 'returns raw text' do get v3_api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -219,7 +219,7 @@ describe API::ProjectSnippets do it 'returns 404 for invalid snippet id' do delete v3_api("/projects/#{snippet.project.id}/snippets/1234", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end diff --git a/spec/requests/api/v3/projects_spec.rb b/spec/requests/api/v3/projects_spec.rb index e5282c3311f..f62ad747c73 100644 --- a/spec/requests/api/v3/projects_spec.rb +++ b/spec/requests/api/v3/projects_spec.rb @@ -44,14 +44,14 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as regular user' do it 'returns an array of projects' do get v3_api('/projects', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(project.name) expect(json_response.first['owner']['username']).to eq(user.username) @@ -94,7 +94,7 @@ describe API::V3::Projects do get v3_api('/projects?simple=true', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first.keys).to match_array expected_keys end @@ -103,7 +103,7 @@ describe API::V3::Projects do context 'and using search' do it 'returns searched project' do get v3_api('/projects', user), { search: project.name } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) end @@ -112,21 +112,21 @@ describe API::V3::Projects do context 'and using the visibility filter' do it 'filters based on private visibility param' do get v3_api('/projects', user), { visibility: 'private' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::PRIVATE).count) end it 'filters based on internal visibility param' do get v3_api('/projects', user), { visibility: 'internal' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::INTERNAL).count) end it 'filters based on public visibility param' do get v3_api('/projects', user), { visibility: 'public' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(user.namespace.projects.where(visibility_level: Gitlab::VisibilityLevel::PUBLIC).count) end @@ -138,7 +138,7 @@ describe API::V3::Projects do it 'returns archived project' do get v3_api('/projects?archived=true', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(archived_project.id) @@ -147,7 +147,7 @@ describe API::V3::Projects do it 'returns non-archived project' do get v3_api('/projects?archived=false', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(1) expect(json_response.first['id']).to eq(project.id) @@ -156,7 +156,7 @@ describe API::V3::Projects do it 'returns all project' do get v3_api('/projects', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) end @@ -170,7 +170,7 @@ describe API::V3::Projects do it 'returns the correct order when sorted by id' do get v3_api('/projects', user), { order_by: 'id', sort: 'desc' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['id']).to eq(project3.id) end @@ -184,21 +184,21 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects/all') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as regular user' do it 'returns authentication error' do get v3_api('/projects/all', user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when authenticated as admin' do it 'returns an array of all projects' do get v3_api('/projects/all', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response).to satisfy do |response| @@ -213,7 +213,7 @@ describe API::V3::Projects do it "does not include statistics by default" do get v3_api('/projects/all', admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first).not_to include('statistics') end @@ -221,7 +221,7 @@ describe API::V3::Projects do it "includes statistics if requested" do get v3_api('/projects/all', admin), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first).to include 'statistics' end @@ -237,14 +237,14 @@ describe API::V3::Projects do context 'when unauthenticated' do it 'returns authentication error' do get v3_api('/projects/owned') - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated as project owner' do it 'returns an array of projects the user owns' do get v3_api('/projects/owned', user4) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(project4.name) expect(json_response.first['owner']['username']).to eq(user4.username) @@ -253,7 +253,7 @@ describe API::V3::Projects do it "does not include statistics by default" do get v3_api('/projects/owned', user4) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first).not_to include('statistics') end @@ -271,7 +271,7 @@ describe API::V3::Projects do get v3_api('/projects/owned', user4), statistics: true - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['statistics']).to eq attributes.stringify_keys end @@ -283,7 +283,7 @@ describe API::V3::Projects do it 'returns the visible projects' do get v3_api('/projects/visible', current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id)) end @@ -329,7 +329,7 @@ describe API::V3::Projects do it 'returns the starred projects viewable by the user' do get v3_api('/projects/starred', user3) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id) end @@ -341,14 +341,14 @@ describe API::V3::Projects do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(0) expect { post v3_api('/projects', user2), name: 'foo' } .to change {Project.count}.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'creates new project without path but with name and returns 201' do expect { post v3_api('/projects', user), name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -359,7 +359,7 @@ describe API::V3::Projects do it 'creates new project without name but with path and returns 201' do expect { post v3_api('/projects', user), path: 'foo_project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -370,7 +370,7 @@ describe API::V3::Projects do it 'creates new project name and path and returns 201' do expect { post v3_api('/projects', user), path: 'foo-Project', name: 'Foo Project' } .to change { Project.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project = Project.first @@ -381,12 +381,12 @@ describe API::V3::Projects do it 'creates last project before reaching project limit' do allow_any_instance_of(User).to receive(:projects_limit_left).and_return(1) post v3_api('/projects', user2), name: 'foo' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'does not create new project without name or path and return 400' do expect { post v3_api('/projects', user) }.not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "assigns attributes to project" do @@ -501,7 +501,7 @@ describe API::V3::Projects do it 'does not allow a non-admin to use a restricted visibility level' do post v3_api('/projects', user), @project - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['visibility_level'].first).to( match('restricted by your GitLab administrator') ) @@ -523,14 +523,14 @@ describe API::V3::Projects do it 'should create new project without path and return 201' do expect { post v3_api("/projects/user/#{user.id}", admin), name: 'foo' }.to change {Project.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end it 'responds with 400 on failure and not project' do expect { post v3_api("/projects/user/#{user.id}", admin) } .not_to change { Project.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('name is missing') end @@ -544,7 +544,7 @@ describe API::V3::Projects do post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project.each_pair do |k, v| next if %i[has_external_issue_tracker path].include?(k) expect(json_response[k.to_s]).to eq(v) @@ -555,7 +555,7 @@ describe API::V3::Projects do project = attributes_for(:project, :public) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_truthy expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC) end @@ -564,7 +564,7 @@ describe API::V3::Projects do project = attributes_for(:project, { public: true }) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_truthy expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::PUBLIC) end @@ -573,7 +573,7 @@ describe API::V3::Projects do project = attributes_for(:project, :internal) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_falsey expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL) end @@ -581,7 +581,7 @@ describe API::V3::Projects do it 'sets a project as internal overriding :public' do project = attributes_for(:project, :internal, { public: true }) post v3_api("/projects/user/#{user.id}", admin), project - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['public']).to be_falsey expect(json_response['visibility_level']).to eq(Gitlab::VisibilityLevel::INTERNAL) end @@ -635,7 +635,7 @@ describe API::V3::Projects do it "uploads the file and returns its info" do post v3_api("/projects/#{project.id}/uploads", user), file: fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png") - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['alt']).to eq("dk") expect(json_response['url']).to start_with("/uploads/") expect(json_response['url']).to end_with("/dk.png") @@ -649,7 +649,7 @@ describe API::V3::Projects do get v3_api("/projects/#{public_project.id}") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(public_project.id) expect(json_response['description']).to eq(public_project.description) expect(json_response['default_branch']).to eq(public_project.default_branch) @@ -668,7 +668,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['id']).to eq(project.id) expect(json_response['description']).to eq(project.description) expect(json_response['default_branch']).to eq(project.default_branch) @@ -710,20 +710,20 @@ describe API::V3::Projects do it 'returns a project by path name' do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'returns a 404 error if not found' do get v3_api('/projects/42', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end it 'returns a 404 error if user is not a member' do other_user = create(:user) get v3_api("/projects/#{project.id}", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'handles users with dots' do @@ -731,14 +731,14 @@ describe API::V3::Projects do project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace) get v3_api("/projects/#{CGI.escape(project.full_path)}", dot_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['name']).to eq(project.name) end it 'exposes namespace fields' do get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['namespace']).to eq({ 'id' => user.namespace.id, 'name' => user.namespace.name, @@ -756,7 +756,7 @@ describe API::V3::Projects do it 'contains permission information' do get v3_api("/projects", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.first['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response.first['permissions']['group_access']).to be_nil @@ -768,7 +768,7 @@ describe API::V3::Projects do project.team << [user, :master] get v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']['access_level']) .to eq(Gitlab::Access::MASTER) expect(json_response['permissions']['group_access']).to be_nil @@ -783,7 +783,7 @@ describe API::V3::Projects do it 'sets the owner and return 200' do get v3_api("/projects/#{project2.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['permissions']['project_access']).to be_nil expect(json_response['permissions']['group_access']['access_level']) .to eq(Gitlab::Access::OWNER) @@ -803,7 +803,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/events", current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) first_event = json_response.first @@ -836,7 +836,7 @@ describe API::V3::Projects do it 'returns a 404 error if not found' do get v3_api('/projects/42/events', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end @@ -845,7 +845,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/events", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -857,7 +857,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/users", current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -886,7 +886,7 @@ describe API::V3::Projects do it 'returns a 404 error if not found' do get v3_api('/projects/42/users', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Project Not Found') end @@ -895,7 +895,7 @@ describe API::V3::Projects do get v3_api("/projects/#{project.id}/users", other_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -905,7 +905,7 @@ describe API::V3::Projects do it 'returns an array of project snippets' do get v3_api("/projects/#{project.id}/snippets", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['title']).to eq(snippet.title) end @@ -914,13 +914,13 @@ describe API::V3::Projects do describe 'GET /projects/:id/snippets/:snippet_id' do it 'returns a project snippet' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(snippet.title) end it 'returns a 404 error if snippet id not found' do get v3_api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -929,7 +929,7 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/snippets", user), title: 'v3_api test', file_name: 'sample.rb', code: 'test', visibility_level: '0' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('v3_api test') end @@ -943,7 +943,7 @@ describe API::V3::Projects do it 'updates an existing project snippet' do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user), code: 'updated code' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('example') expect(snippet.reload.content).to eq('updated code') end @@ -951,7 +951,7 @@ describe API::V3::Projects do it 'updates an existing project snippet with new title' do put v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user), title: 'other v3_api test' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('other v3_api test') end end @@ -963,24 +963,24 @@ describe API::V3::Projects do expect do delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}", user) end.to change { Snippet.count }.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns 404 when deleting unknown snippet id' do delete v3_api("/projects/#{project.id}/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end describe 'GET /projects/:id/snippets/:snippet_id/raw' do it 'gets a raw project snippet' do get v3_api("/projects/#{project.id}/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'returns a 404 error if raw project snippet not found' do get v3_api("/projects/#{project.id}/snippets/5555/raw", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -993,13 +993,13 @@ describe API::V3::Projects do it "is not available for non admin users" do post v3_api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'allows project to be forked from an existing project' do expect(project_fork_target.forked?).not_to be_truthy post v3_api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked_project_link).not_to be_nil @@ -1016,7 +1016,7 @@ describe API::V3::Projects do it 'fails if forked_from project which does not exist' do post v3_api("/projects/#{project_fork_target.id}/fork/9999", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'fails with 409 if already forked' do @@ -1024,7 +1024,7 @@ describe API::V3::Projects do project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) post v3_api("/projects/#{project_fork_target.id}/fork/#{new_project_fork_source.id}", admin) - expect(response).to have_http_status(409) + expect(response).to have_gitlab_http_status(409) project_fork_target.reload expect(project_fork_target.forked_from_project.id).to eq(project_fork_source.id) expect(project_fork_target.forked?).to be_truthy @@ -1034,7 +1034,7 @@ describe API::V3::Projects do describe 'DELETE /projects/:id/fork' do it "is not visible to users outside group" do delete v3_api("/projects/#{project_fork_target.id}/fork", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end context 'when users belong to project group' do @@ -1047,7 +1047,7 @@ describe API::V3::Projects do it 'is forbidden to non-owner users' do delete v3_api("/projects/#{project_fork_target.id}/fork", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'makes forked project unforked' do @@ -1056,7 +1056,7 @@ describe API::V3::Projects do expect(project_fork_target.forked_from_project).not_to be_nil expect(project_fork_target.forked?).to be_truthy delete v3_api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_fork_target.reload expect(project_fork_target.forked_from_project).to be_nil expect(project_fork_target.forked?).not_to be_truthy @@ -1065,7 +1065,7 @@ describe API::V3::Projects do it 'is idempotent if not forked' do expect(project_fork_target.forked_from_project).to be_nil delete v3_api("/projects/#{project_fork_target.id}/fork", admin) - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) expect(project_fork_target.reload.forked_from_project).to be_nil end end @@ -1082,7 +1082,7 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at end.to change { ProjectGroupLink.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['group_id']).to eq(group.id) expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER) expect(json_response['expires_at']).to eq(expires_at.to_s) @@ -1090,18 +1090,18 @@ describe API::V3::Projects do it "returns a 400 error when group id is not given" do post v3_api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when access level is not given" do post v3_api("/projects/#{project.id}/share", user), group_id: group.id - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it "returns a 400 error when sharing is disabled" do project.namespace.update(share_with_group_lock: true) post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when user cannot read group' do @@ -1109,19 +1109,19 @@ describe API::V3::Projects do post v3_api("/projects/#{project.id}/share", user), group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when group does not exist' do post v3_api("/projects/#{project.id}/share", user), group_id: 1234, group_access: Gitlab::Access::DEVELOPER - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it "returns a 400 error when wrong params passed" do post v3_api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234 - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq 'group_access does not have a valid value' end end @@ -1133,26 +1133,26 @@ describe API::V3::Projects do delete v3_api("/projects/#{project.id}/share/#{group.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(project.project_group_links).to be_empty end it 'returns a 400 when group id is not an integer' do delete v3_api("/projects/#{project.id}/share/foo", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 404 error when group link does not exist' do delete v3_api("/projects/#{project.id}/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 error when project does not exist' do delete v3_api("/projects/123/share/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -1173,7 +1173,7 @@ describe API::V3::Projects do it 'returns project search responses' do get v3_api("/projects/search/#{args[:query]}", current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(args[:results]) json_response.each { |project| expect(project['name']).to match(args[:match_regex] || /.*#{args[:query]}.*/) } @@ -1216,7 +1216,7 @@ describe API::V3::Projects do it 'returns authentication error' do project_param = { name: 'bar' } put v3_api("/projects/#{project.id}"), project_param - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -1224,7 +1224,7 @@ describe API::V3::Projects do it 'updates name' do project_param = { name: 'bar' } put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1233,7 +1233,7 @@ describe API::V3::Projects do it 'updates visibility_level' do project_param = { visibility_level: 20 } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1243,7 +1243,7 @@ describe API::V3::Projects do project3.update_attributes({ visibility_level: Gitlab::VisibilityLevel::PUBLIC }) project_param = { public: false } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1253,7 +1253,7 @@ describe API::V3::Projects do it 'does not update name to existing name' do project_param = { name: project3.name } put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['name']).to eq(['has already been taken']) end @@ -1262,14 +1262,14 @@ describe API::V3::Projects do put v3_api("/projects/#{project.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['request_access_enabled']).to eq(false) end it 'updates path & name to existing path & name in different namespace' do project_param = { path: project4.path, name: project4.name } put v3_api("/projects/#{project3.id}", user), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1280,7 +1280,7 @@ describe API::V3::Projects do it 'updates path' do project_param = { path: 'bar' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1294,7 +1294,7 @@ describe API::V3::Projects do description: 'new description' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project_param.each_pair do |k, v| expect(json_response[k.to_s]).to eq(v) end @@ -1303,20 +1303,20 @@ describe API::V3::Projects do it 'does not update path to existing path' do project_param = { path: project.path } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['path']).to eq(['has already been taken']) end it 'does not update name' do project_param = { name: 'bar' } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not update visibility_level' do project_param = { visibility_level: 20 } put v3_api("/projects/#{project3.id}", user4), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1330,7 +1330,7 @@ describe API::V3::Projects do description: 'new description', request_access_enabled: true } put v3_api("/projects/#{project.id}", user3), project_param - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1340,7 +1340,7 @@ describe API::V3::Projects do it 'archives the project' do post v3_api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1353,7 +1353,7 @@ describe API::V3::Projects do it 'remains archived' do post v3_api("/projects/#{project.id}/archive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_truthy end end @@ -1366,7 +1366,7 @@ describe API::V3::Projects do it 'rejects the action' do post v3_api("/projects/#{project.id}/archive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1376,7 +1376,7 @@ describe API::V3::Projects do it 'remains unarchived' do post v3_api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1389,7 +1389,7 @@ describe API::V3::Projects do it 'unarchives the project' do post v3_api("/projects/#{project.id}/unarchive", user) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['archived']).to be_falsey end end @@ -1402,7 +1402,7 @@ describe API::V3::Projects do it 'rejects the action' do post v3_api("/projects/#{project.id}/unarchive", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1412,7 +1412,7 @@ describe API::V3::Projects do it 'stars the project' do expect { post v3_api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['star_count']).to eq(1) end end @@ -1426,7 +1426,7 @@ describe API::V3::Projects do it 'does not modify the star count' do expect { post v3_api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1441,7 +1441,7 @@ describe API::V3::Projects do it 'unstars the project' do expect { delete v3_api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(-1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['star_count']).to eq(0) end end @@ -1450,7 +1450,7 @@ describe API::V3::Projects do it 'does not modify the star count' do expect { delete v3_api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count } - expect(response).to have_http_status(304) + expect(response).to have_gitlab_http_status(304) end end end @@ -1459,36 +1459,36 @@ describe API::V3::Projects do context 'when authenticated as user' do it 'removes project' do delete v3_api("/projects/#{project.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not remove a project if not an owner' do user3 = create(:user) project.team << [user3, :developer] delete v3_api("/projects/#{project.id}", user3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not remove a non existing project' do delete v3_api('/projects/1328', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'does not remove a project not attached to user' do delete v3_api("/projects/#{project.id}", user2) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end context 'when authenticated as admin' do it 'removes any existing project' do delete v3_api("/projects/#{project.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'does not remove a non existing project' do delete v3_api('/projects/1328', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/repositories_spec.rb b/spec/requests/api/v3/repositories_spec.rb index 67624a0bbea..0167eb2c4f6 100644 --- a/spec/requests/api/v3/repositories_spec.rb +++ b/spec/requests/api/v3/repositories_spec.rb @@ -17,7 +17,7 @@ describe API::V3::Repositories do it 'returns the repository tree' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array first_commit = json_response.first @@ -107,7 +107,7 @@ describe API::V3::Repositories do shared_examples_for 'repository blob' do it 'returns the repository blob' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when sha does not exist' do it_behaves_like '404 response' do @@ -162,7 +162,7 @@ describe API::V3::Repositories do shared_examples_for 'repository raw blob' do it 'returns the repository raw blob' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end context 'when sha does not exist' do it_behaves_like '404 response' do @@ -205,7 +205,7 @@ describe API::V3::Repositories do shared_examples_for 'repository archive' do it 'returns the repository archive' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data expect(type).to eq('git-archive') @@ -213,7 +213,7 @@ describe API::V3::Repositories do end it 'returns the repository archive archive.zip' do get v3_api("/projects/#{project.id}/repository/archive.zip", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data expect(type).to eq('git-archive') @@ -221,7 +221,7 @@ describe API::V3::Repositories do end it 'returns the repository archive archive.tar.bz2' do get v3_api("/projects/#{project.id}/repository/archive.tar.bz2", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) repo_name = project.repository.name.gsub("\.git", "") type, params = workhorse_send_data expect(type).to eq('git-archive') @@ -263,32 +263,32 @@ describe API::V3::Repositories do shared_examples_for 'repository compare' do it "compares branches" do get v3_api(route, current_user), from: 'master', to: 'feature' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end it "compares tags" do get v3_api(route, current_user), from: 'v1.0.0', to: 'v1.1.0' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end it "compares commits" do get v3_api(route, current_user), from: sample_commit.id, to: sample_commit.parent_id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_falsey end it "compares commits in reverse order" do get v3_api(route, current_user), from: sample_commit.parent_id, to: sample_commit.id - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_present expect(json_response['diffs']).to be_present end it "compares same refs" do get v3_api(route, current_user), from: 'master', to: 'master' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['commits']).to be_empty expect(json_response['diffs']).to be_empty expect(json_response['compare_same_ref']).to be_truthy @@ -325,7 +325,7 @@ describe API::V3::Repositories do it 'returns valid data' do get v3_api(route, current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array first_contributor = json_response.first diff --git a/spec/requests/api/v3/runners_spec.rb b/spec/requests/api/v3/runners_spec.rb index a31eb3f1d43..c91b097a3c7 100644 --- a/spec/requests/api/v3/runners_spec.rb +++ b/spec/requests/api/v3/runners_spec.rb @@ -37,7 +37,7 @@ describe API::V3::Runners do expect do delete v3_api("/runners/#{shared_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { Ci::Runner.shared.count }.by(-1) end end @@ -47,7 +47,7 @@ describe API::V3::Runners do expect do delete v3_api("/runners/#{unused_specific_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { Ci::Runner.specific.count }.by(-1) end @@ -55,7 +55,7 @@ describe API::V3::Runners do expect do delete v3_api("/runners/#{specific_runner.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { Ci::Runner.specific.count }.by(-1) end end @@ -63,7 +63,7 @@ describe API::V3::Runners do it 'returns 404 if runner does not exists' do delete v3_api('/runners/9999', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -71,26 +71,26 @@ describe API::V3::Runners do context 'when runner is shared' do it 'does not delete runner' do delete v3_api("/runners/#{shared_runner.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end context 'when runner is not shared' do it 'does not delete runner without access to it' do delete v3_api("/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'does not delete runner with more than one associated project' do delete v3_api("/runners/#{two_projects_runner.id}", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'deletes runner for one owned project' do expect do delete v3_api("/runners/#{specific_runner.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { Ci::Runner.specific.count }.by(-1) end end @@ -100,7 +100,7 @@ describe API::V3::Runners do it 'does not delete runner' do delete v3_api("/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -112,7 +112,7 @@ describe API::V3::Runners do expect do delete v3_api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { project.runners.count }.by(-1) end end @@ -122,14 +122,14 @@ describe API::V3::Runners do expect do delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}", user) end.to change { project.runners.count }.by(0) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end it 'returns 404 is runner is not found' do delete v3_api("/projects/#{project.id}/runners/9999", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -137,7 +137,7 @@ describe API::V3::Runners do it "does not disable project's runner" do delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -145,7 +145,7 @@ describe API::V3::Runners do it "does not disable project's runner" do delete v3_api("/projects/#{project.id}/runners/#{specific_runner.id}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/v3/services_spec.rb b/spec/requests/api/v3/services_spec.rb index f0fa48e22df..8f212ab6be6 100644 --- a/spec/requests/api/v3/services_spec.rb +++ b/spec/requests/api/v3/services_spec.rb @@ -13,7 +13,7 @@ describe API::V3::Services do it "deletes #{service}" do delete v3_api("/projects/#{project.id}/services/#{dashed_service}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) project.send(service_method).reload expect(project.send(service_method).activated?).to be_falsey end diff --git a/spec/requests/api/v3/settings_spec.rb b/spec/requests/api/v3/settings_spec.rb index 291f6dcc2aa..25fa0a8aabd 100644 --- a/spec/requests/api/v3/settings_spec.rb +++ b/spec/requests/api/v3/settings_spec.rb @@ -7,7 +7,7 @@ describe API::V3::Settings, 'Settings' do describe "GET /application/settings" do it "returns application settings" do get v3_api("/application/settings", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Hash expect(json_response['default_projects_limit']).to eq(42) expect(json_response['password_authentication_enabled']).to be_truthy @@ -30,7 +30,7 @@ describe API::V3::Settings, 'Settings' do put v3_api("/application/settings", admin), default_projects_limit: 3, password_authentication_enabled: false, repository_storage: 'custom', koding_enabled: true, koding_url: 'http://koding.example.com', plantuml_enabled: true, plantuml_url: 'http://plantuml.example.com' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['default_projects_limit']).to eq(3) expect(json_response['password_authentication_enabled']).to be_falsey expect(json_response['repository_storage']).to eq('custom') @@ -46,7 +46,7 @@ describe API::V3::Settings, 'Settings' do it "returns a blank parameter error message" do put v3_api("/application/settings", admin), koding_enabled: true - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('koding_url is missing') end end @@ -55,7 +55,7 @@ describe API::V3::Settings, 'Settings' do it "returns a blank parameter error message" do put v3_api("/application/settings", admin), plantuml_enabled: true - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('plantuml_url is missing') end end diff --git a/spec/requests/api/v3/snippets_spec.rb b/spec/requests/api/v3/snippets_spec.rb index 79860725634..e8913039194 100644 --- a/spec/requests/api/v3/snippets_spec.rb +++ b/spec/requests/api/v3/snippets_spec.rb @@ -11,7 +11,7 @@ describe API::V3::Snippets do get v3_api("/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( public_snippet.id, internal_snippet.id, @@ -24,7 +24,7 @@ describe API::V3::Snippets do create(:personal_snippet, :private) get v3_api("/snippets/", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(0) end end @@ -41,7 +41,7 @@ describe API::V3::Snippets do it 'returns all snippets with public visibility from all users' do get v3_api("/snippets/public", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly( public_snippet.id, public_snippet_other.id) @@ -60,7 +60,7 @@ describe API::V3::Snippets do it 'returns raw text' do get v3_api("/snippets/#{snippet.id}/raw", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response.content_type).to eq 'text/plain' expect(response.body).to eq(snippet.content) end @@ -68,7 +68,7 @@ describe API::V3::Snippets do it 'returns 404 for invalid snippet id' do delete v3_api("/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end @@ -88,7 +88,7 @@ describe API::V3::Snippets do post v3_api("/snippets/", user), params end.to change { PersonalSnippet.count }.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq(params[:title]) expect(json_response['file_name']).to eq(params[:file_name]) end @@ -98,7 +98,7 @@ describe API::V3::Snippets do post v3_api("/snippets/", user), params - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end context 'when the snippet is spam' do @@ -121,7 +121,7 @@ describe API::V3::Snippets do it 'rejects the shippet' do expect { create_snippet(visibility_level: Snippet::PUBLIC) } .not_to change { Snippet.count } - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'creates a spam log' do @@ -140,7 +140,7 @@ describe API::V3::Snippets do put v3_api("/snippets/#{public_snippet.id}", user), content: new_content - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) public_snippet.reload expect(public_snippet.content).to eq(new_content) end @@ -148,21 +148,21 @@ describe API::V3::Snippets do it 'returns 404 for invalid snippet id' do put v3_api("/snippets/1234", user), title: 'foo' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it "returns 404 for another user's snippet" do put v3_api("/snippets/#{public_snippet.id}", other_user), title: 'fubar' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end it 'returns 400 for missing parameters' do put v3_api("/snippets/1234", user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -172,14 +172,14 @@ describe API::V3::Snippets do expect do delete v3_api("/snippets/#{public_snippet.id}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change { PersonalSnippet.count }.by(-1) end it 'returns 404 for invalid snippet id' do delete v3_api("/snippets/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 Snippet Not Found') end end diff --git a/spec/requests/api/v3/system_hooks_spec.rb b/spec/requests/api/v3/system_hooks_spec.rb index ae427541abb..30711c60faa 100644 --- a/spec/requests/api/v3/system_hooks_spec.rb +++ b/spec/requests/api/v3/system_hooks_spec.rb @@ -12,7 +12,7 @@ describe API::V3::SystemHooks do it "returns authentication error" do get v3_api("/hooks") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -20,7 +20,7 @@ describe API::V3::SystemHooks do it "returns forbidden error" do get v3_api("/hooks", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -28,7 +28,7 @@ describe API::V3::SystemHooks do it "returns an array of hooks" do get v3_api("/hooks", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['url']).to eq(hook.url) expect(json_response.first['push_events']).to be false @@ -43,14 +43,14 @@ describe API::V3::SystemHooks do expect do delete v3_api("/hooks/#{hook.id}", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change { SystemHook.count }.by(-1) end it 'returns 404 if the system hook does not exist' do delete v3_api('/hooks/12345', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/tags_spec.rb b/spec/requests/api/v3/tags_spec.rb index 1c4b25c47c3..e6ad005fa87 100644 --- a/spec/requests/api/v3/tags_spec.rb +++ b/spec/requests/api/v3/tags_spec.rb @@ -17,7 +17,7 @@ describe API::V3::Tags do it 'returns the repository tags' do get v3_api("/projects/#{project.id}/repository/tags", current_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(tag_name) end @@ -40,7 +40,7 @@ describe API::V3::Tags do it "returns an array of project tags" do get v3_api("/projects/#{project.id}/repository/tags", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(tag_name) end @@ -55,7 +55,7 @@ describe API::V3::Tags do it "returns an array of project tags with release info" do get v3_api("/projects/#{project.id}/repository/tags", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).to eq(tag_name) expect(json_response.first['message']).to eq('Version 1.1.0') @@ -75,13 +75,13 @@ describe API::V3::Tags do it 'deletes an existing tag' do delete v3_api("/projects/#{project.id}/repository/tags/#{tag_name}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['tag_name']).to eq(tag_name) end it 'raises 404 if the tag does not exist' do delete v3_api("/projects/#{project.id}/repository/tags/foobar", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/templates_spec.rb b/spec/requests/api/v3/templates_spec.rb index 00446c7f29c..38a8994eb79 100644 --- a/spec/requests/api/v3/templates_spec.rb +++ b/spec/requests/api/v3/templates_spec.rb @@ -19,7 +19,7 @@ describe API::V3::Templates do it 'returns a list of available gitignore templates' do get v3_api(path) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to be > 15 end @@ -29,7 +29,7 @@ describe API::V3::Templates do it 'returns a list of available gitlab_ci_ymls' do get v3_api(path) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['name']).not_to be_nil end @@ -39,7 +39,7 @@ describe API::V3::Templates do it 'adds a disclaimer on the top' do get v3_api(path) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['content']).to start_with("# This file is a template,") end end @@ -66,7 +66,7 @@ describe API::V3::Templates do it 'returns a list of available license templates' do get v3_api(path) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(12) expect(json_response.map { |l| l['key'] }).to include('agpl-3.0') @@ -77,7 +77,7 @@ describe API::V3::Templates do it 'returns a list of available popular license templates' do get v3_api("#{path}?popular=1") - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(3) expect(json_response.map { |l| l['key'] }).to include('apache-2.0') @@ -159,7 +159,7 @@ describe API::V3::Templates do let(:license_type) { 'muth-over9000' } it 'returns a 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end diff --git a/spec/requests/api/v3/triggers_spec.rb b/spec/requests/api/v3/triggers_spec.rb index 7ccf387f2dc..e8e2f49d7a0 100644 --- a/spec/requests/api/v3/triggers_spec.rb +++ b/spec/requests/api/v3/triggers_spec.rb @@ -27,17 +27,17 @@ describe API::V3::Triggers do context 'Handles errors' do it 'returns bad request if token is missing' do post v3_api("/projects/#{project.id}/trigger/builds"), ref: 'master' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns not found if project is not found' do post v3_api('/projects/0/trigger/builds'), options.merge(ref: 'master') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns unauthorized if token is for different project' do post v3_api("/projects/#{project2.id}/trigger/builds"), options.merge(ref: 'master') - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -46,7 +46,7 @@ describe API::V3::Triggers do it 'creates builds' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) pipeline.builds.reload expect(pipeline.builds.pending.size).to eq(2) expect(pipeline.builds.size).to eq(5) @@ -54,7 +54,7 @@ describe API::V3::Triggers do it 'returns bad request with no builds created if there\'s no commit for that ref' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(ref: 'other-branch') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['base']) .to contain_exactly('Reference not found') end @@ -66,19 +66,19 @@ describe API::V3::Triggers do it 'validates variables to be a hash' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(variables: 'value', ref: 'master') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['error']).to eq('variables is invalid') end it 'validates variables needs to be a map of key-valued strings' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(variables: { key: %w(1 2) }, ref: 'master') - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']).to eq('variables needs to be a map of key-valued strings') end it 'creates trigger request with variables' do post v3_api("/projects/#{project.id}/trigger/builds"), options.merge(variables: variables, ref: 'master') - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) pipeline.builds.reload expect(pipeline.variables.map { |v| { v.key => v.value } }.first).to eq(variables) expect(json_response['variables']).to eq(variables) @@ -91,7 +91,7 @@ describe API::V3::Triggers do expect do post v3_api("/projects/#{project.id}/ref/master/trigger/builds?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(5) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end context 'when ref contains a dot' do @@ -102,7 +102,7 @@ describe API::V3::Triggers do post v3_api("/projects/#{project.id}/ref/v.1-branch/trigger/builds?token=#{trigger_token}"), { ref: 'refs/heads/other-branch' } end.to change(project.builds, :count).by(4) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) end end end @@ -113,7 +113,7 @@ describe API::V3::Triggers do it 'returns list of triggers' do get v3_api("/projects/#{project.id}/triggers", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_a(Array) expect(json_response[0]).to have_key('token') @@ -124,7 +124,7 @@ describe API::V3::Triggers do it 'does not return triggers list' do get v3_api("/projects/#{project.id}/triggers", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -132,7 +132,7 @@ describe API::V3::Triggers do it 'does not return triggers list' do get v3_api("/projects/#{project.id}/triggers") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -142,14 +142,14 @@ describe API::V3::Triggers do it 'returns trigger details' do get v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a(Hash) end it 'responds with 404 Not Found if requesting non-existing trigger' do get v3_api("/projects/#{project.id}/triggers/abcdef012345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -157,7 +157,7 @@ describe API::V3::Triggers do it 'does not return triggers list' do get v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -165,7 +165,7 @@ describe API::V3::Triggers do it 'does not return triggers list' do get v3_api("/projects/#{project.id}/triggers/#{trigger.token}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -177,7 +177,7 @@ describe API::V3::Triggers do post v3_api("/projects/#{project.id}/triggers", user) end.to change {project.triggers.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response).to be_a(Hash) end end @@ -186,7 +186,7 @@ describe API::V3::Triggers do it 'does not create trigger' do post v3_api("/projects/#{project.id}/triggers", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -194,7 +194,7 @@ describe API::V3::Triggers do it 'does not create trigger' do post v3_api("/projects/#{project.id}/triggers") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -205,14 +205,14 @@ describe API::V3::Triggers do expect do delete v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end.to change {project.triggers.count}.by(-1) end it 'responds with 404 Not Found if requesting non-existing trigger' do delete v3_api("/projects/#{project.id}/triggers/abcdef012345", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -220,7 +220,7 @@ describe API::V3::Triggers do it 'does not delete trigger' do delete v3_api("/projects/#{project.id}/triggers/#{trigger.token}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -228,7 +228,7 @@ describe API::V3::Triggers do it 'does not delete trigger' do delete v3_api("/projects/#{project.id}/triggers/#{trigger.token}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/v3/users_spec.rb b/spec/requests/api/v3/users_spec.rb index 227b8d1b0c1..bbd05f240d2 100644 --- a/spec/requests/api/v3/users_spec.rb +++ b/spec/requests/api/v3/users_spec.rb @@ -12,7 +12,7 @@ describe API::V3::Users do it 'returns an array of users' do get v3_api('/users', user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array username = user.username @@ -45,14 +45,14 @@ describe API::V3::Users do context 'when unauthenticated' do it 'returns authentication error' do get v3_api("/users/#{user.id}/keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing user' do get v3_api('/users/999999/keys', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -62,7 +62,7 @@ describe API::V3::Users do get v3_api("/users/#{user.id}/keys", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['title']).to eq(key.title) end @@ -88,14 +88,14 @@ describe API::V3::Users do context 'when unauthenticated' do it 'returns authentication error' do get v3_api("/users/#{user.id}/emails") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when authenticated' do it 'returns 404 for non-existing user' do get v3_api('/users/999999/emails', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end @@ -105,7 +105,7 @@ describe API::V3::Users do get v3_api("/users/#{user.id}/emails", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first['email']).to eq(email.email) end @@ -113,7 +113,7 @@ describe API::V3::Users do it "returns a 404 for invalid ID" do put v3_api("/users/ASDF/emails", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -122,7 +122,7 @@ describe API::V3::Users do context "when unauthenticated" do it "returns authentication error" do get v3_api("/user/keys") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -133,7 +133,7 @@ describe API::V3::Users do get v3_api("/user/keys", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first["title"]).to eq(key.title) end @@ -144,7 +144,7 @@ describe API::V3::Users do context "when unauthenticated" do it "returns authentication error" do get v3_api("/user/emails") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -155,7 +155,7 @@ describe API::V3::Users do get v3_api("/user/emails", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.first["email"]).to eq(email.email) end @@ -166,25 +166,25 @@ describe API::V3::Users do before { admin } it 'blocks existing user' do put v3_api("/users/#{user.id}/block", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.state).to eq('blocked') end it 'does not re-block ldap blocked users' do put v3_api("/users/#{ldap_blocked_user.id}/block", admin) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(ldap_blocked_user.reload.state).to eq('ldap_blocked') end it 'does not be available for non admin users' do put v3_api("/users/#{user.id}/block", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(user.reload.state).to eq('active') end it 'returns a 404 error if user id not found' do put v3_api('/users/9999/block', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end end @@ -195,38 +195,38 @@ describe API::V3::Users do it 'unblocks existing user' do put v3_api("/users/#{user.id}/unblock", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(user.reload.state).to eq('active') end it 'unblocks a blocked user' do put v3_api("/users/#{blocked_user.id}/unblock", admin) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(blocked_user.reload.state).to eq('active') end it 'does not unblock ldap blocked users' do put v3_api("/users/#{ldap_blocked_user.id}/unblock", admin) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(ldap_blocked_user.reload.state).to eq('ldap_blocked') end it 'does not be available for non admin users' do put v3_api("/users/#{user.id}/unblock", user) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(user.reload.state).to eq('active') end it 'returns a 404 error if user id not found' do put v3_api('/users/9999/block', admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end it "returns a 404 for invalid ID" do put v3_api("/users/ASDF/block", admin) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -246,7 +246,7 @@ describe API::V3::Users do get api("/users/#{user.id}/events", other_user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_empty end end @@ -262,7 +262,7 @@ describe API::V3::Users do end it 'responds with HTTP 200 OK' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'includes the push payload as a Hash' do @@ -281,7 +281,7 @@ describe API::V3::Users do it 'returns the "joined" event' do get v3_api("/users/#{user.id}/events", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array @@ -327,7 +327,7 @@ describe API::V3::Users do it 'returns a 404 error if not found' do get v3_api('/users/420/events', user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response['message']).to eq('404 User Not Found') end end diff --git a/spec/requests/api/variables_spec.rb b/spec/requests/api/variables_spec.rb index 48592e12822..79ee6c126f6 100644 --- a/spec/requests/api/variables_spec.rb +++ b/spec/requests/api/variables_spec.rb @@ -13,7 +13,7 @@ describe API::Variables do it 'returns project variables' do get api("/projects/#{project.id}/variables", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_a(Array) end end @@ -22,7 +22,7 @@ describe API::Variables do it 'does not return project variables' do get api("/projects/#{project.id}/variables", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -30,7 +30,7 @@ describe API::Variables do it 'does not return project variables' do get api("/projects/#{project.id}/variables") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -40,7 +40,7 @@ describe API::Variables do it 'returns project variable details' do get api("/projects/#{project.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['value']).to eq(variable.value) expect(json_response['protected']).to eq(variable.protected?) end @@ -48,7 +48,7 @@ describe API::Variables do it 'responds with 404 Not Found if requesting non-existing variable' do get api("/projects/#{project.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -56,7 +56,7 @@ describe API::Variables do it 'does not return project variable details' do get api("/projects/#{project.id}/variables/#{variable.key}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -64,7 +64,7 @@ describe API::Variables do it 'does not return project variable details' do get api("/projects/#{project.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -76,7 +76,7 @@ describe API::Variables do post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2', protected: true end.to change {project.variables.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_truthy @@ -87,7 +87,7 @@ describe API::Variables do post api("/projects/#{project.id}/variables", user), key: 'TEST_VARIABLE_2', value: 'VALUE_2' end.to change {project.variables.count}.by(1) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['key']).to eq('TEST_VARIABLE_2') expect(json_response['value']).to eq('VALUE_2') expect(json_response['protected']).to be_falsey @@ -98,7 +98,7 @@ describe API::Variables do post api("/projects/#{project.id}/variables", user), key: variable.key, value: 'VALUE_2' end.to change {project.variables.count}.by(0) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end end @@ -106,7 +106,7 @@ describe API::Variables do it 'does not create variable' do post api("/projects/#{project.id}/variables", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -114,7 +114,7 @@ describe API::Variables do it 'does not create variable' do post api("/projects/#{project.id}/variables") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -129,7 +129,7 @@ describe API::Variables do updated_variable = project.variables.first - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(value_before).to eq(variable.value) expect(updated_variable.value).to eq('VALUE_1_UP') expect(updated_variable).to be_protected @@ -138,7 +138,7 @@ describe API::Variables do it 'responds with 404 Not Found if requesting non-existing variable' do put api("/projects/#{project.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -146,7 +146,7 @@ describe API::Variables do it 'does not update variable' do put api("/projects/#{project.id}/variables/#{variable.key}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -154,7 +154,7 @@ describe API::Variables do it 'does not update variable' do put api("/projects/#{project.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -165,14 +165,14 @@ describe API::Variables do expect do delete api("/projects/#{project.id}/variables/#{variable.key}", user) - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end.to change {project.variables.count}.by(-1) end it 'responds with 404 Not Found if requesting non-existing variable' do delete api("/projects/#{project.id}/variables/non_existing_variable", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -180,7 +180,7 @@ describe API::Variables do it 'does not delete variable' do delete api("/projects/#{project.id}/variables/#{variable.key}", user2) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -188,7 +188,7 @@ describe API::Variables do it 'does not delete variable' do delete api("/projects/#{project.id}/variables/#{variable.key}") - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end diff --git a/spec/requests/api/wikis_spec.rb b/spec/requests/api/wikis_spec.rb index 9e889d1eecf..65bd001e491 100644 --- a/spec/requests/api/wikis_spec.rb +++ b/spec/requests/api/wikis_spec.rb @@ -26,7 +26,7 @@ describe API::Wikis do it 'returns the list of wiki pages without content' do get api(url, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) json_response.each_with_index do |page, index| @@ -39,7 +39,7 @@ describe API::Wikis do it 'returns the list of wiki pages with content' do get api(url, user), with_content: 1 - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(2) json_response.each_with_index do |page, index| @@ -54,14 +54,14 @@ describe API::Wikis do it 'return the empty list of wiki pages' do get api(url, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(0) end end shared_examples_for 'returns wiki page' do it 'returns the wiki page' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(4) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(page.content) @@ -74,7 +74,7 @@ describe API::Wikis do it 'creates the wiki page' do post(api(url, user), payload) - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response.size).to eq(4) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(payload[:content]) @@ -89,7 +89,7 @@ describe API::Wikis do post(api(url, user), payload) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response.size).to eq(1) expect(json_response['error']).to eq("#{part} is missing") end @@ -98,7 +98,7 @@ describe API::Wikis do shared_examples_for 'updates wiki page' do it 'updates the wiki page' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to eq(4) expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response['content']).to eq(payload[:content]) @@ -109,7 +109,7 @@ describe API::Wikis do shared_examples_for '403 Forbidden' do it 'returns 403 Forbidden' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response.size).to eq(1) expect(json_response['message']).to eq('403 Forbidden') end @@ -117,7 +117,7 @@ describe API::Wikis do shared_examples_for '404 Wiki Page Not Found' do it 'returns 404 Wiki Page Not Found' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response.size).to eq(1) expect(json_response['message']).to eq('404 Wiki Page Not Found') end @@ -125,7 +125,7 @@ describe API::Wikis do shared_examples_for '404 Project Not Found' do it 'returns 404 Project Not Found' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) expect(json_response.size).to eq(1) expect(json_response['message']).to eq('404 Project Not Found') end @@ -133,7 +133,7 @@ describe API::Wikis do shared_examples_for '204 No Content' do it 'returns 204 No Content' do - expect(response).to have_http_status(204) + expect(response).to have_gitlab_http_status(204) end end diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index ecac40e301b..cd52194033a 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -9,7 +9,7 @@ describe 'Git HTTP requests' do context "when no credentials are provided" do it "responds to downloads with status 401 Unauthorized (no project existence information leak)" do download(path) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -18,7 +18,7 @@ describe 'Git HTTP requests' do context "when only username is provided" do it "responds to downloads with status 401 Unauthorized" do download(path, user: user.username) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -28,7 +28,7 @@ describe 'Git HTTP requests' do context "when authentication fails" do it "responds to downloads with status 401 Unauthorized" do download(path, user: user.username, password: "wrong-password") do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -37,7 +37,7 @@ describe 'Git HTTP requests' do context "when authentication succeeds" do it "does not respond to downloads with status 401 Unauthorized" do download(path, user: user.username, password: user.password) do |response| - expect(response).not_to have_http_status(:unauthorized) + expect(response).not_to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to be_nil end end @@ -49,7 +49,7 @@ describe 'Git HTTP requests' do context "when no credentials are provided" do it "responds to uploads with status 401 Unauthorized (no project existence information leak)" do upload(path) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -58,7 +58,7 @@ describe 'Git HTTP requests' do context "when only username is provided" do it "responds to uploads with status 401 Unauthorized" do upload(path, user: user.username) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -68,7 +68,7 @@ describe 'Git HTTP requests' do context "when authentication fails" do it "responds to uploads with status 401 Unauthorized" do upload(path, user: user.username, password: "wrong-password") do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to start_with('Basic ') end end @@ -77,7 +77,7 @@ describe 'Git HTTP requests' do context "when authentication succeeds" do it "does not respond to uploads with status 401 Unauthorized" do upload(path, user: user.username, password: user.password) do |response| - expect(response).not_to have_http_status(:unauthorized) + expect(response).not_to have_gitlab_http_status(:unauthorized) expect(response.header['WWW-Authenticate']).to be_nil end end @@ -88,7 +88,7 @@ describe 'Git HTTP requests' do shared_examples_for 'pulls are allowed' do it do download(path, env) do |response| - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) end end @@ -97,7 +97,7 @@ describe 'Git HTTP requests' do shared_examples_for 'pushes are allowed' do it do upload(path, env) do |response| - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) end end @@ -115,7 +115,7 @@ describe 'Git HTTP requests' do context 'when authenticated' do it 'rejects downloads and uploads with 404 Not Found' do download_or_upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -165,7 +165,7 @@ describe 'Git HTTP requests' do it 'rejects pushes with 403 Forbidden' do upload(path, env) do |response| - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_wiki_error(:write_to_wiki)) end end @@ -190,13 +190,13 @@ describe 'Git HTTP requests' do it 'allows clones' do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end it 'pushes are allowed' do upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end end @@ -205,14 +205,14 @@ describe 'Git HTTP requests' do context 'and not on the team' do it 'rejects clones with 404 Not Found' do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to eq(git_access_error(:project_not_found)) end end it 'rejects pushes with 404 Not Found' do upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to eq(git_access_error(:project_not_found)) end end @@ -253,7 +253,7 @@ describe 'Git HTTP requests' do it 'rejects pushes with 403 Forbidden' do upload(path, env) do |response| - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:receive_pack_disabled_over_http)) end end @@ -264,7 +264,7 @@ describe 'Git HTTP requests' do allow(Gitlab.config.gitlab_shell).to receive(:upload_pack).and_return(false) download(path, env) do |response| - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:upload_pack_disabled_over_http)) end end @@ -276,7 +276,7 @@ describe 'Git HTTP requests' do it 'rejects pushes with 403 Forbidden' do upload(path, env) do |response| - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(change_access_error(:push_code)) end end @@ -332,7 +332,7 @@ describe 'Git HTTP requests' do it 'downloads get status 404 with "project was moved" message' do clone_get(path, {}) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to match(project_moved_message) end end @@ -355,7 +355,7 @@ describe 'Git HTTP requests' do clone_get(path, env) - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -374,7 +374,7 @@ describe 'Git HTTP requests' do project.team << [user, :master] download(path, env) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end @@ -382,7 +382,7 @@ describe 'Git HTTP requests' do user.block download('doesnt/exist.git', env) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) end end end @@ -392,7 +392,7 @@ describe 'Git HTTP requests' do expect(Rack::Attack::Allow2Ban).to receive(:reset).twice download(path, env) do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) end end @@ -401,7 +401,7 @@ describe 'Git HTTP requests' do expect(Rack::Attack::Allow2Ban).to receive(:reset).twice upload(path, env) do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) end end @@ -440,14 +440,14 @@ describe 'Git HTTP requests' do context 'when username and password are provided' do it 'rejects pulls with personal access token error message' do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end it 'rejects the push attempt with personal access token error message' do upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -468,14 +468,14 @@ describe 'Git HTTP requests' do it 'rejects pulls with personal access token error message' do download(path, user: 'foo', password: 'bar') do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end it 'rejects pushes with personal access token error message' do upload(path, user: 'foo', password: 'bar') do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -489,7 +489,7 @@ describe 'Git HTTP requests' do it 'does not display the personal access token error message' do upload(path, user: 'foo', password: 'bar') do |response| - expect(response).to have_http_status(:unauthorized) + expect(response).to have_gitlab_http_status(:unauthorized) expect(response.body).not_to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -541,13 +541,13 @@ describe 'Git HTTP requests' do it 'downloads get status 404 with "project was moved" message' do clone_get(path, env) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to match(project_moved_message) end it 'uploads get status 404 with "project was moved" message' do upload(path, env) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to match(project_moved_message) end end @@ -557,13 +557,13 @@ describe 'Git HTTP requests' do context "when the user doesn't have access to the project" do it "pulls get status 404" do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end it "uploads get status 404" do upload(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -595,7 +595,7 @@ describe 'Git HTTP requests' do it "rejects pushes with 403 Forbidden" do push_get(path, env) - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:upload)) end @@ -604,7 +604,7 @@ describe 'Git HTTP requests' do it "rejects pulls for other project with 404 Not Found" do clone_get("#{other_project.full_path}.git", env) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) expect(response.body).to eq(git_access_error(:project_not_found)) end end @@ -627,7 +627,7 @@ describe 'Git HTTP requests' do it 'rejects pulls with 403 Forbidden' do clone_get path, env - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:no_repo)) end end @@ -635,7 +635,7 @@ describe 'Git HTTP requests' do it 'rejects pushes with 403 Forbidden' do push_get path, env - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) expect(response.body).to eq(git_access_error(:upload)) end end @@ -648,7 +648,7 @@ describe 'Git HTTP requests' do it 'downloads from other project get status 403' do clone_get "#{other_project.full_path}.git", user: 'gitlab-ci-token', password: build.token - expect(response).to have_http_status(:forbidden) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -660,7 +660,7 @@ describe 'Git HTTP requests' do it 'downloads from other project get status 404' do clone_get "#{other_project.full_path}.git", user: 'gitlab-ci-token', password: build.token - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -748,7 +748,7 @@ describe 'Git HTTP requests' do end it "returns the file" do - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end @@ -758,7 +758,7 @@ describe 'Git HTTP requests' do end it "returns not found" do - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -783,7 +783,7 @@ describe 'Git HTTP requests' do context "when the project doesn't exist" do it "responds with status 404 Not Found" do download(path, user: user.username, password: user.password) do |response| - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end end end @@ -800,7 +800,7 @@ describe 'Git HTTP requests' do it "responds with status 200" do clone_get(path, env) do |response| - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end diff --git a/spec/requests/jwt_controller_spec.rb b/spec/requests/jwt_controller_spec.rb index 41bf43a9bce..94e04ce5608 100644 --- a/spec/requests/jwt_controller_spec.rb +++ b/spec/requests/jwt_controller_spec.rb @@ -13,12 +13,12 @@ describe JwtController do context 'existing service' do subject! { get '/jwt/auth', parameters } - it { expect(response).to have_http_status(200) } + it { expect(response).to have_gitlab_http_status(200) } context 'returning custom http code' do let(:service) { double(execute: { http_status: 505 }) } - it { expect(response).to have_http_status(505) } + it { expect(response).to have_gitlab_http_status(505) } end end @@ -41,7 +41,7 @@ describe JwtController do subject! { get '/jwt/auth', parameters, headers } - it { expect(response).to have_http_status(401) } + it { expect(response).to have_gitlab_http_status(401) } end context 'using personal access tokens' do @@ -56,7 +56,7 @@ describe JwtController do subject! { get '/jwt/auth', parameters, headers } it 'authenticates correctly' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(service_class).to have_received(:new).with(nil, user, parameters) end end @@ -75,7 +75,7 @@ describe JwtController do context 'without personal token' do it 'rejects the authorization attempt' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -85,7 +85,7 @@ describe JwtController do let(:headers) { { authorization: credentials(user.username, access_token.token) } } it 'accepts the authorization attempt' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -98,7 +98,7 @@ describe JwtController do it 'rejects the authorization attempt' do get '/jwt/auth', parameters, headers - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(response.body).not_to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -108,7 +108,7 @@ describe JwtController do allow_any_instance_of(ApplicationSetting).to receive(:password_authentication_enabled?) { false } get '/jwt/auth', parameters, headers - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP') end end @@ -119,7 +119,7 @@ describe JwtController do it 'accepts the authorization attempt' do get '/jwt/auth', parameters - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'allows read access' do @@ -132,7 +132,7 @@ describe JwtController do context 'unknown service' do subject! { get '/jwt/auth', service: 'unknown' } - it { expect(response).to have_http_status(404) } + it { expect(response).to have_gitlab_http_status(404) } end def credentials(login, password) diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index bca5bf81c5c..52e93e157f1 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -41,7 +41,7 @@ describe 'Git LFS API and storage' do end it 'responds with 501' do - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) expect(json_response).to include('message' => 'Git LFS is not enabled on this GitLab server, contact your admin.') end end @@ -75,13 +75,13 @@ describe 'Git LFS API and storage' do it 'responds with a 501 message on upload' do post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end it 'responds with a 501 message on download' do get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end end @@ -93,13 +93,13 @@ describe 'Git LFS API and storage' do it 'responds with a 501 message on upload' do post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end it 'responds with a 501 message on download' do get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end end end @@ -118,14 +118,14 @@ describe 'Git LFS API and storage' do it 'responds with a 403 message on upload' do post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response).to include('message' => 'Access forbidden. Check your access level.') end it 'responds with a 403 message on download' do get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) expect(json_response).to include('message' => 'Access forbidden. Check your access level.') end end @@ -138,14 +138,14 @@ describe 'Git LFS API and storage' do it 'responds with a 200 message on upload' do post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['objects'].first['size']).to eq(1575078) end it 'responds with a 200 message on download' do get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", nil, headers - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end end @@ -160,7 +160,7 @@ describe 'Git LFS API and storage' do shared_examples 'a deprecated' do it 'responds with 501' do - expect(response).to have_http_status(501) + expect(response).to have_gitlab_http_status(501) end it 'returns deprecated message' do @@ -201,7 +201,7 @@ describe 'Git LFS API and storage' do context 'and request comes from gitlab-workhorse' do context 'without user being authorized' do it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -210,7 +210,7 @@ describe 'Git LFS API and storage' do let(:sendfile) { 'X-Sendfile' } it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with the file location' do @@ -228,7 +228,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -272,7 +272,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -311,7 +311,7 @@ describe 'Git LFS API and storage' do end it 'rejects downloading code' do - expect(response).to have_http_status(other_project_status) + expect(response).to have_gitlab_http_status(other_project_status) end end end @@ -351,7 +351,7 @@ describe 'Git LFS API and storage' do let(:authorization) { authorize_user } it 'responds with status 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -387,7 +387,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'with href to download' do @@ -415,7 +415,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'with href to download' do @@ -446,7 +446,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'with an 404 for specific object' do @@ -483,7 +483,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with upload hypermedia link for the new object' do @@ -528,7 +528,7 @@ describe 'Git LFS API and storage' do let(:update_user_permissions) { nil } it 'responds with 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -536,7 +536,7 @@ describe 'Git LFS API and storage' do let(:role) { :guest } it 'responds with 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -564,7 +564,7 @@ describe 'Git LFS API and storage' do let(:pipeline) { create(:ci_empty_pipeline, project: other_project) } it 'rejects downloading code' do - expect(response).to have_http_status(other_project_status) + expect(response).to have_gitlab_http_status(other_project_status) end end end @@ -608,7 +608,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200 and href to download' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with status 200 and href to download' do @@ -636,7 +636,7 @@ describe 'Git LFS API and storage' do end it 'responds with authorization required' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -669,7 +669,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with links the object to the project' do @@ -695,7 +695,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with upload hypermedia link' do @@ -725,7 +725,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'responds with upload hypermedia link for the new object' do @@ -747,7 +747,7 @@ describe 'Git LFS API and storage' do let(:authorization) { authorize_user } it 'responds with 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -761,7 +761,7 @@ describe 'Git LFS API and storage' do let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) } it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -772,7 +772,7 @@ describe 'Git LFS API and storage' do # I'm not sure what this tests that is different from the previous test it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -781,7 +781,7 @@ describe 'Git LFS API and storage' do let(:build) { create(:ci_build, :running, pipeline: pipeline) } it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -794,13 +794,13 @@ describe 'Git LFS API and storage' do end it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end context 'when user does not have push access' do it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -820,7 +820,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 404' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -865,7 +865,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -875,7 +875,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 401' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end @@ -885,7 +885,7 @@ describe 'Git LFS API and storage' do end it 'does not recognize it as a valid lfs command' do - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end end end @@ -897,7 +897,7 @@ describe 'Git LFS API and storage' do end it 'responds with 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -907,7 +907,7 @@ describe 'Git LFS API and storage' do end it 'responds with 403' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -917,7 +917,7 @@ describe 'Git LFS API and storage' do end it 'does not recognize it as a valid lfs command' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -945,7 +945,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'uses the gitlab-workhorse content type' do @@ -965,7 +965,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'lfs object is linked to the project' do @@ -976,12 +976,12 @@ describe 'Git LFS API and storage' do context 'invalid tempfiles' do it 'rejects slashes in the tempfile name (path traversal' do put_finalize('foo/bar') - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end it 'rejects tempfile names that do not start with the oid' do put_finalize("foo#{sample_oid}") - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1010,7 +1010,7 @@ describe 'Git LFS API and storage' do end it 'responds with 403 (not 404 because the build user can read the project)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1024,7 +1024,7 @@ describe 'Git LFS API and storage' do end it 'responds with 404 (do not leak non-public project existence)' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1037,7 +1037,7 @@ describe 'Git LFS API and storage' do end it 'responds with 404 (do not leak non-public project existence)' do - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end end @@ -1066,7 +1066,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'with location of lfs store and object details' do @@ -1082,7 +1082,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'lfs object is linked to the source project' do @@ -1110,7 +1110,7 @@ describe 'Git LFS API and storage' do let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) } it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end @@ -1121,7 +1121,7 @@ describe 'Git LFS API and storage' do # I'm not sure what this tests that is different from the previous test it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1130,7 +1130,7 @@ describe 'Git LFS API and storage' do let(:build) { create(:ci_build, :running, pipeline: pipeline) } it 'responds with 403 (not 404 because project is public)' do - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -1155,7 +1155,7 @@ describe 'Git LFS API and storage' do end it 'responds with status 200' do - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end it 'links the lfs object to the project' do diff --git a/spec/requests/openid_connect_spec.rb b/spec/requests/openid_connect_spec.rb index a927de952d0..0b1f8ce6f6d 100644 --- a/spec/requests/openid_connect_spec.rb +++ b/spec/requests/openid_connect_spec.rb @@ -37,7 +37,7 @@ describe 'OpenID Connect requests' do it 'userinfo response is unauthorized' do request_user_info - expect(response).to have_http_status 403 + expect(response).to have_gitlab_http_status 403 expect(response.body).to be_blank end end diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb index 6667ce771bd..286d8a884a4 100644 --- a/spec/requests/projects/cycle_analytics_events_spec.rb +++ b/spec/requests/projects/cycle_analytics_events_spec.rb @@ -99,19 +99,19 @@ describe 'cycle analytics events' do it 'does not list the test events' do get project_cycle_analytics_test_path(project, format: :json) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end it 'does not list the staging events' do get project_cycle_analytics_staging_path(project, format: :json) - expect(response).to have_http_status(:not_found) + expect(response).to have_gitlab_http_status(:not_found) end it 'lists the issue events' do get project_cycle_analytics_issue_path(project, format: :json) - expect(response).to have_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) end end end diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index a45839b16f5..407d19c3b2a 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -285,17 +285,15 @@ end describe "Groups", "routing" do let(:name) { 'complex.group-namegit' } - - before do - allow_any_instance_of(GroupUrlConstrainer).to receive(:matches?).and_return(true) - end + let!(:group) { create(:group, name: name) } it "to #show" do expect(get("/groups/#{name}")).to route_to('groups#show', id: name) end it "also supports nested groups" do - expect(get("/#{name}/#{name}")).to route_to('groups#show', id: "#{name}/#{name}") + nested_group = create(:group, parent: group) + expect(get("/#{name}/#{nested_group.name}")).to route_to('groups#show', id: "#{name}/#{nested_group.name}") end it "also display group#show on the short path" do @@ -313,10 +311,6 @@ describe "Groups", "routing" do it "to #members" do expect(get("/groups/#{name}/group_members")).to route_to('groups/group_members#index', group_id: name) end - - it "also display group#show with slash in the path" do - expect(get('/group/subgroup')).to route_to('groups#show', id: 'group/subgroup') - end end describe HealthCheckController, 'routing' do diff --git a/spec/services/users/last_push_event_service_spec.rb b/spec/services/users/last_push_event_service_spec.rb index 956358738fe..2b6c0267a0f 100644 --- a/spec/services/users/last_push_event_service_spec.rb +++ b/spec/services/users/last_push_event_service_spec.rb @@ -22,7 +22,6 @@ describe Users::LastPushEventService do it 'caches the event for the origin project when pushing to a fork' do source = build(:project, id: 5) - allow(project).to receive(:forked?).and_return(true) allow(project).to receive(:forked_from_project).and_return(source) expect(service).to receive(:set_key) diff --git a/spec/support/api/issues_resolving_discussions_shared_examples.rb b/spec/support/api/issues_resolving_discussions_shared_examples.rb index d26d279363c..d2d6260dfa8 100644 --- a/spec/support/api/issues_resolving_discussions_shared_examples.rb +++ b/spec/support/api/issues_resolving_discussions_shared_examples.rb @@ -1,6 +1,6 @@ shared_examples 'creating an issue resolving discussions through the API' do it 'creates a new project issue' do - expect(response).to have_http_status(:created) + expect(response).to have_gitlab_http_status(:created) end it 'resolves the discussions in a merge request' do diff --git a/spec/support/api/members_shared_examples.rb b/spec/support/api/members_shared_examples.rb index dab71a35a55..8d910e52eda 100644 --- a/spec/support/api/members_shared_examples.rb +++ b/spec/support/api/members_shared_examples.rb @@ -6,6 +6,6 @@ shared_examples 'a 404 response when source is private' do it 'returns 404' do route - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end diff --git a/spec/support/api/milestones_shared_examples.rb b/spec/support/api/milestones_shared_examples.rb index 4bb5113957e..d9080b02541 100644 --- a/spec/support/api/milestones_shared_examples.rb +++ b/spec/support/api/milestones_shared_examples.rb @@ -10,7 +10,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns milestones list' do get api(route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['title']).to eq(milestone.title) @@ -19,13 +19,13 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a 401 error if user not authenticated' do get api(route) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns an array of active milestones' do get api("#{route}/?state=active", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -35,7 +35,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns an array of closed milestones' do get api("#{route}/?state=closed", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.length).to eq(1) @@ -47,7 +47,7 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(route, user), iids: [closed_milestone.iid, other_milestone.iid] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(2) expect(json_response.map { |m| m['id'] }).to match_array([closed_milestone.id, other_milestone.id]) @@ -56,7 +56,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'does not return any milestone if none found' do get api(route, user), iids: [Milestone.maximum(:iid).succ] - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.length).to eq(0) end @@ -75,7 +75,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a milestone by searching for title' do get api(route, user), search: 'version2' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.size).to eq(1) expect(json_response.first['title']).to eq milestone.title @@ -85,7 +85,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a milestones by searching for description' do get api(route, user), search: 'open' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response.size).to eq(1) expect(json_response.first['title']).to eq milestone.title @@ -97,7 +97,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a milestone by id' do get api(resource_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(milestone.title) expect(json_response['iid']).to eq(milestone.iid) end @@ -105,7 +105,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a milestone by id' do get api(resource_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq(milestone.title) expect(json_response['iid']).to eq(milestone.iid) end @@ -113,13 +113,13 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns 401 error if user not authenticated' do get api(resource_route) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns a 404 error if milestone id not found' do get api("#{route}/1234", user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end end @@ -127,7 +127,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'creates a new milestone' do post api(route, user), title: 'new milestone' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('new milestone') expect(json_response['description']).to be_nil end @@ -136,7 +136,7 @@ shared_examples_for 'group and project milestones' do |route_definition| post api(route, user), title: 'new milestone', description: 'release', due_date: '2013-03-02', start_date: '2013-02-02' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['description']).to eq('release') expect(json_response['due_date']).to eq('2013-03-02') expect(json_response['start_date']).to eq('2013-02-02') @@ -145,20 +145,20 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns a 400 error if title is missing' do post api(route, user) - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'returns a 400 error if params are invalid (duplicate title)' do post api(route, user), title: milestone.title, description: 'release', due_date: '2013-03-02' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) end it 'creates a new milestone with reserved html characters' do post api(route, user), title: 'foo & bar 1.1 -> 2.2' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['title']).to eq('foo & bar 1.1 -> 2.2') expect(json_response['description']).to be_nil end @@ -169,7 +169,7 @@ shared_examples_for 'group and project milestones' do |route_definition| put api(resource_route, user), title: 'updated title' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['title']).to eq('updated title') end @@ -178,7 +178,7 @@ shared_examples_for 'group and project milestones' do |route_definition| put api(resource_route, user), due_date: nil - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['due_date']).to be_nil end @@ -186,13 +186,13 @@ shared_examples_for 'group and project milestones' do |route_definition| put api("#{route}/1234", user), title: 'updated title' - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'closes milestone' do put api(resource_route, user), state_event: 'close' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['state']).to eq('closed') end @@ -207,7 +207,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns issues for a particular milestone' do get api(issues_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.first['milestone']['title']).to eq(milestone.title) @@ -228,14 +228,14 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'matches V4 response schema for a list of issues' do get api(issues_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to match_response_schema('public_api/v4/issues') end it 'returns a 401 error if user not authenticated' do get api(issues_route) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end describe 'confidential issues' do @@ -265,7 +265,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'returns confidential issues to team members' do get api(issues_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array # 2 for projects, 3 for group(which has another project with an issue) @@ -279,7 +279,7 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(issues_route, member) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -289,7 +289,7 @@ shared_examples_for 'group and project milestones' do |route_definition| it 'does not return confidential issues to regular users' do get api(issues_route, create(:user)) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(1) @@ -302,7 +302,7 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(issues_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array # 2 for projects, 3 for group(which has another project with an issue) @@ -325,7 +325,7 @@ shared_examples_for 'group and project milestones' do |route_definition| another_merge_request get api(merge_requests_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to be_an Array expect(json_response.size).to eq(1) expect(json_response.first['title']).to eq(merge_request.title) @@ -349,20 +349,20 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(not_found_route, user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 404 if the user has no access to the milestone' do new_user = create :user get api(merge_requests_route, new_user) - expect(response).to have_http_status(404) + expect(response).to have_gitlab_http_status(404) end it 'returns a 401 error if user not authenticated' do get api(merge_requests_route) - expect(response).to have_http_status(401) + expect(response).to have_gitlab_http_status(401) end it 'returns merge_requests ordered by position asc' do @@ -372,7 +372,7 @@ shared_examples_for 'group and project milestones' do |route_definition| get api(merge_requests_route, user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(response).to include_pagination_headers expect(json_response).to be_an Array expect(json_response.size).to eq(2) diff --git a/spec/support/api/scopes/read_user_shared_examples.rb b/spec/support/api/scopes/read_user_shared_examples.rb index 111534f2f26..06ae8792c61 100644 --- a/spec/support/api/scopes/read_user_shared_examples.rb +++ b/spec/support/api/scopes/read_user_shared_examples.rb @@ -6,7 +6,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "200" response' do get api_call.call(path, user, personal_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -16,7 +16,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "200" response' do get api_call.call(path, user, personal_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -30,7 +30,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "403" response' do get api_call.call(path, user, personal_access_token: token) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -44,7 +44,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "200" response' do get api_call.call(path, user, oauth_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -54,7 +54,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "200" response' do get api_call.call(path, user, oauth_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) end end @@ -64,7 +64,7 @@ shared_examples_for 'allows the "read_user" scope' do it 'returns a "403" response' do get api_call.call(path, user, oauth_access_token: token) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end @@ -77,7 +77,7 @@ shared_examples_for 'does not allow the "read_user" scope' do it 'returns a "403" response' do post api_call.call(path, user, personal_access_token: token), attributes_for(:user, projects_limit: 3) - expect(response).to have_http_status(403) + expect(response).to have_gitlab_http_status(403) end end end diff --git a/spec/support/api/time_tracking_shared_examples.rb b/spec/support/api/time_tracking_shared_examples.rb index 16a3cf06be7..af1083f4bfd 100644 --- a/spec/support/api/time_tracking_shared_examples.rb +++ b/spec/support/api/time_tracking_shared_examples.rb @@ -15,7 +15,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it "sets the time estimate for #{issuable_name}" do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), duration: '1w' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['human_time_estimate']).to eq('1w') end @@ -28,7 +28,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it 'does not modify the original estimate' do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), duration: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(issuable.reload.human_time_estimate).to eq('1w') end end @@ -37,7 +37,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it 'updates the estimate' do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), duration: '3w1h' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(issuable.reload.human_time_estimate).to eq('3w 1h') end end @@ -54,7 +54,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it "resets the time estimate for #{issuable_name}" do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_time_estimate", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['time_estimate']).to eq(0) end end @@ -73,7 +73,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), duration: '2h' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['human_total_time_spent']).to eq('2h') end @@ -84,7 +84,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), duration: '-1h' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['total_time_spent']).to eq(3600) end end @@ -96,7 +96,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), duration: '-1w' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['time_spent'].first).to match(/exceeds the total time spent/) end end @@ -112,7 +112,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| it "resets spent time for #{issuable_name}" do post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_spent_time", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(0) end end @@ -124,7 +124,7 @@ shared_examples 'time tracking endpoints' do |issuable_name| get api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_stats", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(1800) expect(json_response['time_estimate']).to eq(3600) end diff --git a/spec/support/api/v3/time_tracking_shared_examples.rb b/spec/support/api/v3/time_tracking_shared_examples.rb index f982b10d999..afe0f4cecda 100644 --- a/spec/support/api/v3/time_tracking_shared_examples.rb +++ b/spec/support/api/v3/time_tracking_shared_examples.rb @@ -11,7 +11,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it "sets the time estimate for #{issuable_name}" do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/time_estimate", user), duration: '1w' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['human_time_estimate']).to eq('1w') end @@ -24,7 +24,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it 'does not modify the original estimate' do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/time_estimate", user), duration: 'foo' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(issuable.reload.human_time_estimate).to eq('1w') end end @@ -33,7 +33,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it 'updates the estimate' do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/time_estimate", user), duration: '3w1h' - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(issuable.reload.human_time_estimate).to eq('3w 1h') end end @@ -50,7 +50,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it "resets the time estimate for #{issuable_name}" do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/reset_time_estimate", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['time_estimate']).to eq(0) end end @@ -69,7 +69,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/add_spent_time", user), duration: '2h' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['human_total_time_spent']).to eq('2h') end @@ -80,7 +80,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/add_spent_time", user), duration: '-1h' - expect(response).to have_http_status(201) + expect(response).to have_gitlab_http_status(201) expect(json_response['total_time_spent']).to eq(3600) end end @@ -92,7 +92,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/add_spent_time", user), duration: '-1w' - expect(response).to have_http_status(400) + expect(response).to have_gitlab_http_status(400) expect(json_response['message']['time_spent'].first).to match(/exceeds the total time spent/) end end @@ -108,7 +108,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| it "resets spent time for #{issuable_name}" do post v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/reset_spent_time", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(0) end end @@ -120,7 +120,7 @@ shared_examples 'V3 time tracking endpoints' do |issuable_name| get v3_api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.id}/time_stats", user) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response['total_time_spent']).to eq(1800) expect(json_response['time_estimate']).to eq(3600) end diff --git a/spec/support/jira_service_helper.rb b/spec/support/jira_service_helper.rb index 0b5f66597fd..88a7aeba461 100644 --- a/spec/support/jira_service_helper.rb +++ b/spec/support/jira_service_helper.rb @@ -6,6 +6,8 @@ module JiraServiceHelper properties = { title: "JIRA tracker", url: JIRA_URL, + username: 'jira-user', + password: 'my-secret-password', project_key: "JIRA", jira_issue_transition_id: '1' } 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 c9302f7b750..6bc39f2f279 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 @@ -9,7 +9,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| it 'does not filter by custom attributes' do get api("/#{attributable_name}", user), custom_attributes: { foo: 'foo', bar: 'bar' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to be 2 end end @@ -17,7 +17,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| it 'filters by custom attributes' do get api("/#{attributable_name}", admin), custom_attributes: { foo: 'foo', bar: 'bar' } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response.size).to be 1 expect(json_response.first['id']).to eq attributable.id end @@ -33,7 +33,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_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to contain_exactly( { 'key' => 'foo', 'value' => 'foo' }, { 'key' => 'bar', 'value' => 'bar' } @@ -51,7 +51,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_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq({ 'key' => 'foo', 'value' => 'foo' }) end end @@ -68,7 +68,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| put api("/#{attributable_name}/#{attributable.id}/custom_attributes/new", admin), value: 'new' end.to change { attributable.custom_attributes.count }.by(1) - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq({ 'key' => 'new', 'value' => 'new' }) expect(attributable.custom_attributes.find_by(key: 'new').value).to eq 'new' end @@ -78,7 +78,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin), value: 'new' end.not_to change { attributable.custom_attributes.count } - expect(response).to have_http_status(200) + expect(response).to have_gitlab_http_status(200) expect(json_response).to eq({ 'key' => 'foo', 'value' => 'new' }) expect(custom_attribute1.reload.value).to eq 'new' end @@ -96,7 +96,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_http_status(204) + expect(response).to have_gitlab_http_status(204) expect(attributable.custom_attributes.find_by(key: 'foo')).to be_nil end end diff --git a/spec/support/unique_ip_check_shared_examples.rb b/spec/support/unique_ip_check_shared_examples.rb index 2dfa5fbecea..3d9705c9c05 100644 --- a/spec/support/unique_ip_check_shared_examples.rb +++ b/spec/support/unique_ip_check_shared_examples.rb @@ -56,13 +56,13 @@ shared_examples 'user login request with unique ip limit' do |success_status = 2 end it 'allows user authenticating from the same ip' do - expect(request_from_ip('ip')).to have_http_status(success_status) - expect(request_from_ip('ip')).to have_http_status(success_status) + expect(request_from_ip('ip')).to have_gitlab_http_status(success_status) + expect(request_from_ip('ip')).to have_gitlab_http_status(success_status) end it 'blocks user authenticating from two distinct ips' do - expect(request_from_ip('ip')).to have_http_status(success_status) - expect(request_from_ip('ip2')).to have_http_status(403) + expect(request_from_ip('ip')).to have_gitlab_http_status(success_status) + expect(request_from_ip('ip2')).to have_gitlab_http_status(403) end end end diff --git a/spec/support/update_invalid_issuable.rb b/spec/support/update_invalid_issuable.rb index 50a1d4a56e2..1490287681b 100644 --- a/spec/support/update_invalid_issuable.rb +++ b/spec/support/update_invalid_issuable.rb @@ -25,13 +25,11 @@ shared_examples 'update invalid issuable' do |klass| .and_raise(ActiveRecord::StaleObjectError.new(issuable, :save)) end - if klass == MergeRequest - it 'renders edit when format is html' do - put :update, params + it 'renders edit when format is html' do + put :update, params - expect(response).to render_template(:edit) - expect(assigns[:conflict]).to be_truthy - end + expect(response).to render_template(:edit) + expect(assigns[:conflict]).to be_truthy end it 'renders json error message when format is json' do @@ -44,17 +42,16 @@ shared_examples 'update invalid issuable' do |klass| end end - if klass == MergeRequest - context 'when updating an invalid issuable' do - before do - params[:merge_request][:title] = "" - end + context 'when updating an invalid issuable' do + before do + key = klass == Issue ? :issue : :merge_request + params[key][:title] = "" + end - it 'renders edit when merge request is invalid' do - put :update, params + it 'renders edit when merge request is invalid' do + put :update, params - expect(response).to render_template(:edit) - end + expect(response).to render_template(:edit) end end end diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb index c030129559e..0a78606171d 100644 --- a/spec/views/help/index.html.haml_spec.rb +++ b/spec/views/help/index.html.haml_spec.rb @@ -25,6 +25,14 @@ describe 'help/index' do end end + describe 'instance configuration link' do + it 'is visible to guests' do + render + + expect(rendered).to have_link(nil, help_instance_configuration_url) + end + end + def stub_user(user = double) allow(view).to receive(:user_signed_in?).and_return(user) end diff --git a/spec/views/help/instance_configuration.html.haml_spec.rb b/spec/views/help/instance_configuration.html.haml_spec.rb new file mode 100644 index 00000000000..f30b5881fde --- /dev/null +++ b/spec/views/help/instance_configuration.html.haml_spec.rb @@ -0,0 +1,29 @@ +require 'rails_helper' + +describe 'help/instance_configuration' do + describe 'General Sections:' do + let(:instance_configuration) { build(:instance_configuration)} + let(:settings) { instance_configuration.settings } + let(:ssh_settings) { settings[:ssh_algorithms_hashes] } + + before do + assign(:instance_configuration, instance_configuration) + end + + it 'has links to several sections' do + render + + expect(rendered).to have_link(nil, '#ssh-host-keys-fingerprints') if ssh_settings.any? + expect(rendered).to have_link(nil, '#gitlab-pages') + expect(rendered).to have_link(nil, '#gitlab-ci') + end + + it 'has several sections' do + render + + expect(rendered).to have_css('h2#ssh-host-keys-fingerprints') if ssh_settings.any? + expect(rendered).to have_css('h2#gitlab-pages') + expect(rendered).to have_css('h2#gitlab-ci') + end + end +end