Commit db24ab2b authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 7e8278c0
...@@ -347,6 +347,8 @@ RSpec/HaveGitlabHttpStatus: ...@@ -347,6 +347,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/features/**/*' - 'ee/spec/features/**/*'
- 'spec/controllers/*.rb' - 'spec/controllers/*.rb'
- 'ee/spec/controllers/*.rb' - 'ee/spec/controllers/*.rb'
- 'spec/controllers/projects/*.rb'
- 'ee/spec/controllers/projects/*.rb'
- 'spec/requests/*.rb' - 'spec/requests/*.rb'
- 'ee/spec/requests/*.rb' - 'ee/spec/requests/*.rb'
......
...@@ -11,7 +11,7 @@ export default () => { ...@@ -11,7 +11,7 @@ export default () => {
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new BlobLinePermalinkUpdater( new BlobLinePermalinkUpdater(
document.querySelector('#blob-content-holder'), document.querySelector('#blob-content-holder'),
'.diff-line-num[data-line-number]', '.diff-line-num[data-line-number], .diff-line-num[data-line-number] *',
document.querySelectorAll('.js-data-file-blob-permalink-url, .js-blob-blame-link'), document.querySelectorAll('.js-data-file-blob-permalink-url, .js-blob-blame-link'),
); );
......
...@@ -6,14 +6,24 @@ class SentNotificationsController < ApplicationController ...@@ -6,14 +6,24 @@ class SentNotificationsController < ApplicationController
def unsubscribe def unsubscribe
@sent_notification = SentNotification.for(params[:id]) @sent_notification = SentNotification.for(params[:id])
return render_404 unless @sent_notification && @sent_notification.unsubscribable? return render_404 unless unsubscribe_prerequisites_met?
return unsubscribe_and_redirect if current_user || params[:force] return unsubscribe_and_redirect if current_user || params[:force]
end end
private private
def unsubscribe_prerequisites_met?
@sent_notification.present? &&
@sent_notification.unsubscribable? &&
noteable.present?
end
def noteable
@sent_notification.noteable
end
def unsubscribe_and_redirect def unsubscribe_and_redirect
noteable = @sent_notification.noteable
noteable.unsubscribe(@sent_notification.recipient, @sent_notification.project) noteable.unsubscribe(@sent_notification.recipient, @sent_notification.project)
flash[:notice] = _("You have been unsubscribed from this thread.") flash[:notice] = _("You have been unsubscribed from this thread.")
......
---
title: Fix 500 error when trying to unsubscribe from an already deleted entity
merge_request: 23747
author:
type: fixed
---
title: Fix hash parameter of Permalink and Blame button
merge_request: 23713
author:
type: fixed
...@@ -15,7 +15,7 @@ The Packages feature allows GitLab to act as a repository for the following: ...@@ -15,7 +15,7 @@ The Packages feature allows GitLab to act as a repository for the following:
Don't you see your package management system supported yet? Don't you see your package management system supported yet?
Please consider contributing Please consider contributing
to GitLab. This [development documentation](../../development/packages.md) will guide you through the process, it includes a list of [suggested contributions](../../development/packages.md#suggested-contributions). to GitLab. This [development documentation](../../development/packages.md) will guide you through the process.
## Enabling the Packages feature ## Enabling the Packages feature
......
...@@ -77,7 +77,7 @@ and cross-link between any related content. ...@@ -77,7 +77,7 @@ and cross-link between any related content.
We employ a **docs-first methodology** to help ensure that the docs remain a complete and trusted resource, and to make communicating about the use of GitLab more efficient. We employ a **docs-first methodology** to help ensure that the docs remain a complete and trusted resource, and to make communicating about the use of GitLab more efficient.
- If the answer to a question exists in documentation, share the link to the docs instead of rephrasing the information. - If the answer to a question exists in documentation, share the link to the docs instead of rephrasing the information.
- When you encounter new information not available in GitLab’s documentation (for example, when working on a support case or testing a feature), your first step should be to create a merge request to add this information to the docs. You can then share the MR in order to communicate this information. - When you encounter new information not available in GitLab’s documentation (for example, when working on a support case or testing a feature), your first step should be to create a merge request (MR) to add this information to the docs. You can then share the MR in order to communicate this information.
New information that would be useful toward the future usage or troubleshooting of GitLab should not be written directly in a forum or other messaging system, but added to a docs MR and then referenced, as described above. Note that among any other doc changes, you can always add a Troubleshooting section to a doc if none exists, or un-comment and use the placeholder Troubleshooting section included as part of our [doc template](structure.md#template-for-new-docs), if present. New information that would be useful toward the future usage or troubleshooting of GitLab should not be written directly in a forum or other messaging system, but added to a docs MR and then referenced, as described above. Note that among any other doc changes, you can always add a Troubleshooting section to a doc if none exists, or un-comment and use the placeholder Troubleshooting section included as part of our [doc template](structure.md#template-for-new-docs), if present.
...@@ -525,6 +525,35 @@ For other punctuation rules, please refer to the ...@@ -525,6 +525,35 @@ For other punctuation rules, please refer to the
- Use sentence case in headings. Do not capitalize the words of the title, unless - Use sentence case in headings. Do not capitalize the words of the title, unless
it refers to a product feature. For example, capitalizing "issues" is acceptable in it refers to a product feature. For example, capitalizing "issues" is acceptable in
`## What you can do with GitLab Issues`, but not in `## Closing multiple issues`. `## What you can do with GitLab Issues`, but not in `## Closing multiple issues`.
- Our docs site search engine prioritizes headings, therefore, make sure to write
headings that contextualize the subject and help to take the user to the right
document. For example, `## Examples` is a bad heading; `## GitLab Pages examples`
is a better one. It's not an exact science, but please consider this carefully.
### Anchor links
Headings generate anchor links automatically when rendered. `## This is an example`
generates the anchor `#this-is-an-example`.
Keep in mind that the GitLab UI links to a large number of docs and respective
anchor links to take the user to the right spot. Therefore, when you change a
heading, search `doc/*`, `app/views/*`, and `ee/app/views/*` for the old anchor
to make sure you're not breaking an anchor linked from other docs nor from the
GitLab UI. If you find the old anchor, make sure to replace it with the new one.
Important:
- Avoid crosslinking docs to headings unless you need to link to a specific section
of the document. This will avoid breaking anchors in the future in case the heading
is changed.
- If possible, avoid changing headings since they're not only linked internally.
There are various links to GitLab documentation on the internet, such as tutorials,
presentations, StackOverflow posts, and other sources.
- Do not link to `h1` headings.
Note that, with Kramdown, it is possible to add a custom ID to an HTML element
with Markdown markup, but they **do not** work in GitLab's `/help`. Therefore,
do not use this option until further notice.
## Links ## Links
...@@ -953,6 +982,24 @@ Which renders to: ...@@ -953,6 +982,24 @@ Which renders to:
To maintain consistency through GitLab documentation, the following guides documentation authors To maintain consistency through GitLab documentation, the following guides documentation authors
on agreed styles and usage of terms. on agreed styles and usage of terms.
### Merge Requests (MRs)
Merge requests allow you to exchange changes you made to source code and collaborate
with other people on the same project. You'll see this term used in the following ways:
- If you're referring to the feature, use **Merge Request**.
- In any other context, use **merge request**.
As noted in our corporate [Writing Style Guidelines](https://about.gitlab.com/handbook/communication/#writing-style-guidelines),
if you use the **MR** acronym, expand it at least once per document page.
For example, the first time you specify a MR, specify either _Merge Request (MR)_ or _merge request (MR)_.
Examples:
- "We prefer GitLab Merge Requests".
- "Open a merge request to fix a broken link".
- "After you open a merge request (MR), submit your MR for review and approval".
### Describing UI elements ### Describing UI elements
The following are styles to follow when describing UI elements on a screen: The following are styles to follow when describing UI elements on a screen:
......
...@@ -14,29 +14,6 @@ by looking at existing merge requests with Maven and NPM support: ...@@ -14,29 +14,6 @@ by looking at existing merge requests with Maven and NPM support:
- [Maven repository](https://gitlab.com/gitlab-org/gitlab/merge_requests/6607). - [Maven repository](https://gitlab.com/gitlab-org/gitlab/merge_requests/6607).
- [Instance level endpoint for Maven repository](https://gitlab.com/gitlab-org/gitlab/merge_requests/8757) - [Instance level endpoint for Maven repository](https://gitlab.com/gitlab-org/gitlab/merge_requests/8757)
## Suggested contributions
The goal of the Package group is to build a set of features that, within three years, will allow ninety percent of our customers to store all of their packages in GitLab. To do that we need to ensure that we support the below package manager formats.
| Format | Use case |
| ------ | ------ |
| [Bower](https://gitlab.com/gitlab-org/gitlab/issues/36888) | Boost your front end development by hosting your own Bower components. |
| [Cargo](https://gitlab.com/gitlab-org/gitlab/issues/33060) | Cargo is the Rust package manager. Build, publish and share Rust packages |
| [Chef](https://gitlab.com/gitlab-org/gitlab/issues/36889) | Configuration management with Chef using all the benefits of a repository manager. |
| [CocoaPods](https://gitlab.com/gitlab-org/gitlab/issues/36890) | Speed up development with Xcode and CocoaPods. |
| [Conda](https://gitlab.com/gitlab-org/gitlab/issues/36891) | Secure and private local Conda repositories. |
| [CRAN](https://gitlab.com/gitlab-org/gitlab/issues/36892) | Deploy and resolve CRAN packages for the R language. |
| [Debian](https://gitlab.com/gitlab-org/gitlab/issues/5835) | Host and provision Debian packages. |
| [Go](https://gitlab.com/gitlab-org/gitlab/issues/9773) | Resolve Go dependencies from and publish your Go packages to GitLab. |
| [Opkg](https://gitlab.com/gitlab-org/gitlab/issues/36894) | Optimize your work with OpenWrt using Opkg repositories. |
| [P2](https://gitlab.com/gitlab-org/gitlab/issues/36895) | Host all your Eclipse plugins in your own GitLab P2 repository. |
| [Puppet](https://gitlab.com/gitlab-org/gitlab/issues/36897) | Configuration management meets repository management with Puppet repositories. |
| [PyPi](https://gitlab.com/gitlab-org/gitlab/issues/10483) | Host PyPi distributions. |
| [RPM](https://gitlab.com/gitlab-org/gitlab/issues/5932) | Distribute RPMs directly from GitLab. |
| [RubyGems](https://gitlab.com/gitlab-org/gitlab/issues/803) | Use GitLab to host your own gems. |
| [SBT](https://gitlab.com/gitlab-org/gitlab/issues/36898) | Resolve dependencies from and deploy build output to SBT repositories when running SBT builds. |
| [Vagrant](https://gitlab.com/gitlab-org/gitlab/issues/36899) | Securely host your Vagrant boxes in local repositories. |
## General information ## General information
The existing database model requires the following: The existing database model requires the following:
......
...@@ -15,13 +15,29 @@ The Packages feature allows GitLab to act as a repository for the following: ...@@ -15,13 +15,29 @@ The Packages feature allows GitLab to act as a repository for the following:
| [NPM Registry](npm_registry/index.md) **(PREMIUM)** | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ | | [NPM Registry](npm_registry/index.md) **(PREMIUM)** | The GitLab NPM Registry enables every project in GitLab to have its own space to store [NPM](https://www.npmjs.com/) packages. | 11.7+ |
| [NuGet Repository](nuget_repository/index.md) **(PREMIUM)** | *PLANNED* The GitLab NuGet Repository will enable every project in GitLab to have its own space to store [NuGet](https://www.nuget.org/) packages. | 12.8+ | | [NuGet Repository](nuget_repository/index.md) **(PREMIUM)** | *PLANNED* The GitLab NuGet Repository will enable every project in GitLab to have its own space to store [NuGet](https://www.nuget.org/) packages. | 12.8+ |
TIP: **Tip:** ## Suggested contributions
Don't you see your package management system supported yet? Consider contributing
to GitLab. This [development documentation](../../development/packages.md) will Consider contributing to GitLab. This [development documentation](../../development/packages.md) will
guide you through the process. Or check out how other members of the community guide you through the process. Or check out how other members of the community
are adding support for [PHP](https://gitlab.com/gitlab-org/gitlab/merge_requests/17417) or [Terraform](https://gitlab.com/gitlab-org/gitlab/merge_requests/18834). are adding support for [PHP](https://gitlab.com/gitlab-org/gitlab/merge_requests/17417) or [Terraform](https://gitlab.com/gitlab-org/gitlab/merge_requests/18834).
NOTE: **Note** We are especially interested in adding support for [PyPi](https://gitlab.com/gitlab-org/gitlab/issues/10483), [RubyGems](https://gitlab.com/gitlab-org/gitlab/issues/803), [Debian](https://gitlab.com/gitlab-org/gitlab/issues/5835), and [RPM](https://gitlab.com/gitlab-org/gitlab/issues/5932). | Format | Use case |
| ------ | ------ |
| [Cargo](https://gitlab.com/gitlab-org/gitlab/issues/33060) | Cargo is the Rust package manager. Build, publish and share Rust packages |
| [Chef](https://gitlab.com/gitlab-org/gitlab/issues/36889) | Configuration management with Chef using all the benefits of a repository manager. |
| [CocoaPods](https://gitlab.com/gitlab-org/gitlab/issues/36890) | Speed up development with Xcode and CocoaPods. |
| [Conda](https://gitlab.com/gitlab-org/gitlab/issues/36891) | Secure and private local Conda repositories. |
| [CRAN](https://gitlab.com/gitlab-org/gitlab/issues/36892) | Deploy and resolve CRAN packages for the R language. |
| [Debian](https://gitlab.com/gitlab-org/gitlab/issues/5835) | Host and provision Debian packages. |
| [Go](https://gitlab.com/gitlab-org/gitlab/issues/9773) | Resolve Go dependencies from and publish your Go packages to GitLab. |
| [Opkg](https://gitlab.com/gitlab-org/gitlab/issues/36894) | Optimize your work with OpenWrt using Opkg repositories. |
| [P2](https://gitlab.com/gitlab-org/gitlab/issues/36895) | Host all your Eclipse plugins in your own GitLab P2 repository. |
| [Puppet](https://gitlab.com/gitlab-org/gitlab/issues/36897) | Configuration management meets repository management with Puppet repositories. |
| [PyPi](https://gitlab.com/gitlab-org/gitlab/issues/10483) | Host PyPi distributions. |
| [RPM](https://gitlab.com/gitlab-org/gitlab/issues/5932) | Distribute RPMs directly from GitLab. |
| [RubyGems](https://gitlab.com/gitlab-org/gitlab/issues/803) | Use GitLab to host your own gems. |
| [SBT](https://gitlab.com/gitlab-org/gitlab/issues/36898) | Resolve dependencies from and deploy build output to SBT repositories when running SBT builds. |
| [Vagrant](https://gitlab.com/gitlab-org/gitlab/issues/36899) | Securely host your Vagrant boxes in local repositories. |
## Package workflows ## Package workflows
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
module API module API
class GroupExport < Grape::API class GroupExport < Grape::API
before do before do
not_found! unless Feature.enabled?(:group_import_export, user_group, default_enabled: true)
authorize! :admin_group, user_group authorize! :admin_group, user_group
end end
......
...@@ -47,7 +47,7 @@ module API ...@@ -47,7 +47,7 @@ module API
SCOPE_ENTITY[params[:scope].to_sym] SCOPE_ENTITY[params[:scope].to_sym]
end end
def verify_search_scope! def verify_search_scope!(resource:)
# In EE we have additional validation requirements for searches. # In EE we have additional validation requirements for searches.
# Defining this method here as a noop allows us to easily extend it in # Defining this method here as a noop allows us to easily extend it in
# EE, without having to modify this file directly. # EE, without having to modify this file directly.
...@@ -73,7 +73,7 @@ module API ...@@ -73,7 +73,7 @@ module API
use :pagination use :pagination
end end
get do get do
verify_search_scope! verify_search_scope!(resource: nil)
check_users_search_allowed! check_users_search_allowed!
present search, with: entity present search, with: entity
...@@ -94,7 +94,7 @@ module API ...@@ -94,7 +94,7 @@ module API
use :pagination use :pagination
end end
get ':id/(-/)search' do get ':id/(-/)search' do
verify_search_scope! verify_search_scope!(resource: user_group)
check_users_search_allowed! check_users_search_allowed!
present search(group_id: user_group.id), with: entity present search(group_id: user_group.id), with: entity
......
...@@ -12,12 +12,6 @@ module QA ...@@ -12,12 +12,6 @@ module QA
yield yield
# Workaround for a bug preventing sign out from secondary nodes
# See https://gitlab.com/gitlab-org/gitlab/issues/198289
if address == :geo_secondary
Runtime::Browser.visit(:geo_primary, Page::Dashboard::Projects)
end
Page::Main::Menu.perform(&:sign_out) Page::Main::Menu.perform(&:sign_out)
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
context 'Create', quarantine: 'https://gitlab.com/gitlab-org/gitlab/issues/196034' do context 'Create' do
describe 'Web IDE file templates' do describe 'Web IDE file templates' do
include Runtime::Fixtures include Runtime::Fixtures
......
...@@ -156,7 +156,7 @@ describe Projects::ArtifactsController do ...@@ -156,7 +156,7 @@ describe Projects::ArtifactsController do
it 'returns 404' do it 'returns 404' do
download_artifact(file_type: file_type) download_artifact(file_type: file_type)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -236,7 +236,7 @@ describe Projects::ArtifactsController do ...@@ -236,7 +236,7 @@ describe Projects::ArtifactsController do
it 'renders the file view' do it 'renders the file view' do
get :file, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'ci_artifacts.txt' } get :file, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'ci_artifacts.txt' }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -302,7 +302,7 @@ describe Projects::ArtifactsController do ...@@ -302,7 +302,7 @@ describe Projects::ArtifactsController do
it 'renders the file view' do it 'renders the file view' do
get :file, params: { namespace_id: private_project.namespace, project_id: private_project, job_id: job, path: 'ci_artifacts.txt' } get :file, params: { namespace_id: private_project.namespace, project_id: private_project, job_id: job, path: 'ci_artifacts.txt' }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -317,7 +317,7 @@ describe Projects::ArtifactsController do ...@@ -317,7 +317,7 @@ describe Projects::ArtifactsController do
it 'serves the file using workhorse' do it 'serves the file using workhorse' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(send_data).to start_with('artifacts-entry:') expect(send_data).to start_with('artifacts-entry:')
expect(params.keys).to eq(%w(Archive Entry)) expect(params.keys).to eq(%w(Archive Entry))
......
...@@ -65,7 +65,7 @@ describe Projects::AutocompleteSourcesController do ...@@ -65,7 +65,7 @@ describe Projects::AutocompleteSourcesController do
get :milestones, format: :json, params: { namespace_id: group.path, project_id: project.path } get :milestones, format: :json, params: { namespace_id: group.path, project_id: project.path }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -16,7 +16,7 @@ describe Projects::AvatarsController do ...@@ -16,7 +16,7 @@ describe Projects::AvatarsController do
it 'shows 404' do it 'shows 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -31,7 +31,7 @@ describe Projects::AvatarsController do ...@@ -31,7 +31,7 @@ describe Projects::AvatarsController do
it 'sends the avatar' do it 'sends the avatar' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.header['Content-Disposition']).to eq('inline') expect(response.header['Content-Disposition']).to eq('inline')
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
......
...@@ -232,7 +232,7 @@ describe Projects::BlobController do ...@@ -232,7 +232,7 @@ describe Projects::BlobController do
end end
it 'redirects to blob show' do it 'redirects to blob show' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -246,7 +246,7 @@ describe Projects::BlobController do ...@@ -246,7 +246,7 @@ describe Projects::BlobController do
end end
it 'redirects to blob show' do it 'redirects to blob show' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
......
...@@ -39,7 +39,7 @@ describe Projects::BoardsController do ...@@ -39,7 +39,7 @@ describe Projects::BoardsController do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
list_boards list_boards
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.content_type).to eq 'text/html' expect(response.content_type).to eq 'text/html'
end end
end end
...@@ -82,7 +82,7 @@ describe Projects::BoardsController do ...@@ -82,7 +82,7 @@ describe Projects::BoardsController do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
list_boards format: :json list_boards format: :json
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
end end
end end
...@@ -94,7 +94,7 @@ describe Projects::BoardsController do ...@@ -94,7 +94,7 @@ describe Projects::BoardsController do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
list_boards list_boards
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -137,7 +137,7 @@ describe Projects::BoardsController do ...@@ -137,7 +137,7 @@ describe Projects::BoardsController do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
read_board board: board read_board board: board
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.content_type).to eq 'text/html' expect(response.content_type).to eq 'text/html'
end end
end end
...@@ -174,7 +174,7 @@ describe Projects::BoardsController do ...@@ -174,7 +174,7 @@ describe Projects::BoardsController do
it 'returns a not found 404 response' do it 'returns a not found 404 response' do
read_board board: board, format: :json read_board board: board, format: :json
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
end end
end end
...@@ -186,7 +186,7 @@ describe Projects::BoardsController do ...@@ -186,7 +186,7 @@ describe Projects::BoardsController do
read_board board: another_board read_board board: another_board
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -217,7 +217,7 @@ describe Projects::BranchesController do ...@@ -217,7 +217,7 @@ describe Projects::BranchesController do
} }
expect(response.location).to include(project_new_blob_path(project, branch)) expect(response.location).to include(project_new_blob_path(project, branch))
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -238,7 +238,7 @@ describe Projects::BranchesController do ...@@ -238,7 +238,7 @@ describe Projects::BranchesController do
} }
expect(response.location).to include(project_new_blob_path(project, branch)) expect(response.location).to include(project_new_blob_path(project, branch))
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -289,7 +289,7 @@ describe Projects::BranchesController do ...@@ -289,7 +289,7 @@ describe Projects::BranchesController do
it 'returns a successful 200 response' do it 'returns a successful 200 response' do
create_branch name: 'my-branch', ref: 'master' create_branch name: 'my-branch', ref: 'master'
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'returns the created branch' do it 'returns the created branch' do
...@@ -303,7 +303,7 @@ describe Projects::BranchesController do ...@@ -303,7 +303,7 @@ describe Projects::BranchesController do
it 'returns an unprocessable entity 422 response' do it 'returns an unprocessable entity 422 response' do
create_branch name: "<script>alert('merge');</script>", ref: "<script>alert('ref');</script>" create_branch name: "<script>alert('merge');</script>", ref: "<script>alert('ref');</script>"
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
...@@ -335,7 +335,7 @@ describe Projects::BranchesController do ...@@ -335,7 +335,7 @@ describe Projects::BranchesController do
project_id: project project_id: project
} }
expect(response).to have_gitlab_http_status(303) expect(response).to have_gitlab_http_status(:see_other)
end end
end end
...@@ -361,28 +361,28 @@ describe Projects::BranchesController do ...@@ -361,28 +361,28 @@ describe Projects::BranchesController do
context "valid branch name, valid source" do context "valid branch name, valid source" do
let(:branch) { "feature" } let(:branch) { "feature" }
it { expect(response).to have_gitlab_http_status(200) } it { expect(response).to have_gitlab_http_status(:ok) }
it { expect(response.body).to be_blank } it { expect(response.body).to be_blank }
end end
context "valid branch name with unencoded slashes" do context "valid branch name with unencoded slashes" do
let(:branch) { "improve/awesome" } let(:branch) { "improve/awesome" }
it { expect(response).to have_gitlab_http_status(200) } it { expect(response).to have_gitlab_http_status(:ok) }
it { expect(response.body).to be_blank } it { expect(response.body).to be_blank }
end end
context "valid branch name with encoded slashes" do context "valid branch name with encoded slashes" do
let(:branch) { "improve%2Fawesome" } let(:branch) { "improve%2Fawesome" }
it { expect(response).to have_gitlab_http_status(200) } it { expect(response).to have_gitlab_http_status(:ok) }
it { expect(response.body).to be_blank } it { expect(response.body).to be_blank }
end end
context "invalid branch name, valid ref" do context "invalid branch name, valid ref" do
let(:branch) { "no-branch" } let(:branch) { "no-branch" }
it { expect(response).to have_gitlab_http_status(404) } it { expect(response).to have_gitlab_http_status(:not_found) }
it { expect(response.body).to be_blank } it { expect(response.body).to be_blank }
end end
end end
...@@ -398,7 +398,7 @@ describe Projects::BranchesController do ...@@ -398,7 +398,7 @@ describe Projects::BranchesController do
expect(json_response).to eql("message" => 'Branch was deleted') expect(json_response).to eql("message" => 'Branch was deleted')
end end
it { expect(response).to have_gitlab_http_status(200) } it { expect(response).to have_gitlab_http_status(:ok) }
end end
context 'valid branch name with unencoded slashes' do context 'valid branch name with unencoded slashes' do
...@@ -408,7 +408,7 @@ describe Projects::BranchesController do ...@@ -408,7 +408,7 @@ describe Projects::BranchesController do
expect(json_response).to eql('message' => 'Branch was deleted') expect(json_response).to eql('message' => 'Branch was deleted')
end end
it { expect(response).to have_gitlab_http_status(200) } it { expect(response).to have_gitlab_http_status(:ok) }
end end
context "valid branch name with encoded slashes" do context "valid branch name with encoded slashes" do
...@@ -418,7 +418,7 @@ describe Projects::BranchesController do ...@@ -418,7 +418,7 @@ describe Projects::BranchesController do
expect(json_response).to eql('message' => 'Branch was deleted') expect(json_response).to eql('message' => 'Branch was deleted')
end end
it { expect(response).to have_gitlab_http_status(200) } it { expect(response).to have_gitlab_http_status(:ok) }
end end
context 'invalid branch name, valid ref' do context 'invalid branch name, valid ref' do
...@@ -428,7 +428,7 @@ describe Projects::BranchesController do ...@@ -428,7 +428,7 @@ describe Projects::BranchesController do
expect(json_response).to eql('message' => 'No such branch') expect(json_response).to eql('message' => 'No such branch')
end end
it { expect(response).to have_gitlab_http_status(404) } it { expect(response).to have_gitlab_http_status(:not_found) }
end end
end end
...@@ -478,7 +478,7 @@ describe Projects::BranchesController do ...@@ -478,7 +478,7 @@ describe Projects::BranchesController do
it 'responds with status 404' do it 'responds with status 404' do
destroy_all_merged destroy_all_merged
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -519,7 +519,7 @@ describe Projects::BranchesController do ...@@ -519,7 +519,7 @@ describe Projects::BranchesController do
state: 'all' state: 'all'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -537,7 +537,7 @@ describe Projects::BranchesController do ...@@ -537,7 +537,7 @@ describe Projects::BranchesController do
state: 'all' state: 'all'
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -594,7 +594,7 @@ describe Projects::BranchesController do ...@@ -594,7 +594,7 @@ describe Projects::BranchesController do
names: %w[fix add-pdf-file branch-merged] names: %w[fix add-pdf-file branch-merged]
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq( expect(json_response).to eq(
"fix" => { "behind" => 29, "ahead" => 2 }, "fix" => { "behind" => 29, "ahead" => 2 },
"branch-merged" => { "behind" => 1, "ahead" => 0 }, "branch-merged" => { "behind" => 1, "ahead" => 0 },
...@@ -612,7 +612,7 @@ describe Projects::BranchesController do ...@@ -612,7 +612,7 @@ describe Projects::BranchesController do
project_id: project project_id: project
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.count).to be > 1 expect(json_response.count).to be > 1
end end
...@@ -629,7 +629,7 @@ describe Projects::BranchesController do ...@@ -629,7 +629,7 @@ describe Projects::BranchesController do
project_id: project project_id: project
} }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response['error']).to eq("Specify at least one and at most #{Kaminari.config.default_per_page} branch names") expect(json_response['error']).to eq("Specify at least one and at most #{Kaminari.config.default_per_page} branch names")
end end
...@@ -642,7 +642,7 @@ describe Projects::BranchesController do ...@@ -642,7 +642,7 @@ describe Projects::BranchesController do
names: %w[fix add-pdf-file branch-merged] names: %w[fix add-pdf-file branch-merged]
} }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.count).to be > 1 expect(json_response.count).to be > 1
end end
end end
......
...@@ -648,7 +648,7 @@ describe Projects::ClustersController do ...@@ -648,7 +648,7 @@ describe Projects::ClustersController do
go(format: :json) go(format: :json)
cluster.reload cluster.reload
expect(response).to have_http_status(:no_content) expect(response).to have_gitlab_http_status(:no_content)
expect(cluster.enabled).to be_falsey expect(cluster.enabled).to be_falsey
expect(cluster.name).to eq('my-new-cluster-name') expect(cluster.name).to eq('my-new-cluster-name')
expect(cluster).not_to be_managed expect(cluster).not_to be_managed
...@@ -671,7 +671,7 @@ describe Projects::ClustersController do ...@@ -671,7 +671,7 @@ describe Projects::ClustersController do
it "rejects changes" do it "rejects changes" do
go(format: :json) go(format: :json)
expect(response).to have_http_status(:bad_request) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
......
...@@ -179,7 +179,7 @@ describe Projects::CommitController do ...@@ -179,7 +179,7 @@ describe Projects::CommitController do
}) })
expect(response).not_to be_successful expect(response).not_to be_successful
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -236,7 +236,7 @@ describe Projects::CommitController do ...@@ -236,7 +236,7 @@ describe Projects::CommitController do
}) })
expect(response).not_to be_successful expect(response).not_to be_successful
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -322,7 +322,7 @@ describe Projects::CommitController do ...@@ -322,7 +322,7 @@ describe Projects::CommitController do
end end
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -334,7 +334,7 @@ describe Projects::CommitController do ...@@ -334,7 +334,7 @@ describe Projects::CommitController do
end end
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -345,7 +345,7 @@ describe Projects::CommitController do ...@@ -345,7 +345,7 @@ describe Projects::CommitController do
end end
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -393,7 +393,7 @@ describe Projects::CommitController do ...@@ -393,7 +393,7 @@ describe Projects::CommitController do
end end
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -108,7 +108,7 @@ describe Projects::CompareController do ...@@ -108,7 +108,7 @@ describe Projects::CompareController do
show_request show_request
expect(flash[:alert]).to eq('Invalid branch name') expect(flash[:alert]).to eq('Invalid branch name')
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -120,7 +120,7 @@ describe Projects::CompareController do ...@@ -120,7 +120,7 @@ describe Projects::CompareController do
show_request show_request
expect(flash[:alert]).to eq('Invalid branch name') expect(flash[:alert]).to eq('Invalid branch name')
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -164,7 +164,7 @@ describe Projects::CompareController do ...@@ -164,7 +164,7 @@ describe Projects::CompareController do
end end
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -176,7 +176,7 @@ describe Projects::CompareController do ...@@ -176,7 +176,7 @@ describe Projects::CompareController do
end end
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -187,7 +187,7 @@ describe Projects::CompareController do ...@@ -187,7 +187,7 @@ describe Projects::CompareController do
end end
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -197,7 +197,7 @@ describe Projects::CompareController do ...@@ -197,7 +197,7 @@ describe Projects::CompareController do
end end
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -301,7 +301,7 @@ describe Projects::CompareController do ...@@ -301,7 +301,7 @@ describe Projects::CompareController do
it 'returns only the commit with a signature' do it 'returns only the commit with a signature' do
signatures_request signatures_request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
signatures = json_response['signatures'] signatures = json_response['signatures']
expect(signatures.size).to eq(1) expect(signatures.size).to eq(1)
...@@ -318,7 +318,7 @@ describe Projects::CompareController do ...@@ -318,7 +318,7 @@ describe Projects::CompareController do
it 'returns a 404' do it 'returns a 404' do
signatures_request signatures_request
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -330,7 +330,7 @@ describe Projects::CompareController do ...@@ -330,7 +330,7 @@ describe Projects::CompareController do
it 'returns no signatures' do it 'returns no signatures' do
signatures_request signatures_request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['signatures']).to be_empty expect(json_response['signatures']).to be_empty
end end
end end
...@@ -342,7 +342,7 @@ describe Projects::CompareController do ...@@ -342,7 +342,7 @@ describe Projects::CompareController do
it 'returns no signatures' do it 'returns no signatures' do
signatures_request signatures_request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['signatures']).to be_empty expect(json_response['signatures']).to be_empty
end end
end end
......
...@@ -122,7 +122,7 @@ describe Projects::DeployKeysController do ...@@ -122,7 +122,7 @@ describe Projects::DeployKeysController do
put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
end.not_to change { DeployKeysProject.count } end.not_to change { DeployKeysProject.count }
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(new_user_session_path) expect(response).to redirect_to(new_user_session_path)
end end
end end
...@@ -137,7 +137,7 @@ describe Projects::DeployKeysController do ...@@ -137,7 +137,7 @@ describe Projects::DeployKeysController do
put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
end.not_to change { DeployKeysProject.count } end.not_to change { DeployKeysProject.count }
expect(response).to have_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -152,14 +152,14 @@ describe Projects::DeployKeysController do ...@@ -152,14 +152,14 @@ describe Projects::DeployKeysController do
end.to change { DeployKeysProject.count }.by(1) end.to change { DeployKeysProject.count }.by(1)
expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1) expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1)
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings'))
end end
it 'returns 404' do it 'returns 404' do
put :enable, params: { id: 0, namespace_id: project.namespace, project_id: project } put :enable, params: { id: 0, namespace_id: project.namespace, project_id: project }
expect(response).to have_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -174,7 +174,7 @@ describe Projects::DeployKeysController do ...@@ -174,7 +174,7 @@ describe Projects::DeployKeysController do
end.to change { DeployKeysProject.count }.by(1) end.to change { DeployKeysProject.count }.by(1)
expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1) expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1)
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings'))
end end
end end
...@@ -192,7 +192,7 @@ describe Projects::DeployKeysController do ...@@ -192,7 +192,7 @@ describe Projects::DeployKeysController do
it 'redirects to login' do it 'redirects to login' do
put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(new_user_session_path) expect(response).to redirect_to(new_user_session_path)
expect(DeployKey.find(deploy_key.id)).to eq(deploy_key) expect(DeployKey.find(deploy_key.id)).to eq(deploy_key)
end end
...@@ -206,7 +206,7 @@ describe Projects::DeployKeysController do ...@@ -206,7 +206,7 @@ describe Projects::DeployKeysController do
it 'returns 404' do it 'returns 404' do
put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
expect(response).to have_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(DeployKey.find(deploy_key.id)).to eq(deploy_key) expect(DeployKey.find(deploy_key.id)).to eq(deploy_key)
end end
end end
...@@ -215,7 +215,7 @@ describe Projects::DeployKeysController do ...@@ -215,7 +215,7 @@ describe Projects::DeployKeysController do
it 'returns 302' do it 'returns 302' do
put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings'))
expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound) expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound)
...@@ -224,7 +224,7 @@ describe Projects::DeployKeysController do ...@@ -224,7 +224,7 @@ describe Projects::DeployKeysController do
it 'returns 404' do it 'returns 404' do
put :disable, params: { id: 0, namespace_id: project.namespace, project_id: project } put :disable, params: { id: 0, namespace_id: project.namespace, project_id: project }
expect(response).to have_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -238,7 +238,7 @@ describe Projects::DeployKeysController do ...@@ -238,7 +238,7 @@ describe Projects::DeployKeysController do
put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project } put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
end.to change { DeployKey.count }.by(-1) end.to change { DeployKey.count }.by(-1)
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings')) expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings'))
expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound) expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound)
......
...@@ -61,7 +61,7 @@ describe Projects::DeploymentsController do ...@@ -61,7 +61,7 @@ describe Projects::DeploymentsController do
it 'returns a empty response 204 resposne' do it 'returns a empty response 204 resposne' do
get :metrics, params: deployment_params(id: deployment.to_param) get :metrics, params: deployment_params(id: deployment.to_param)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(response.body).to eq('') expect(response.body).to eq('')
end end
end end
...@@ -100,7 +100,7 @@ describe Projects::DeploymentsController do ...@@ -100,7 +100,7 @@ describe Projects::DeploymentsController do
get :metrics, params: deployment_params(id: failed_deployment.to_param) get :metrics, params: deployment_params(id: failed_deployment.to_param)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -129,7 +129,7 @@ describe Projects::DeploymentsController do ...@@ -129,7 +129,7 @@ describe Projects::DeploymentsController do
it 'returns a empty response 204 response' do it 'returns a empty response 204 response' do
get :additional_metrics, params: deployment_params(id: deployment.to_param, format: :json) get :additional_metrics, params: deployment_params(id: deployment.to_param, format: :json)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(response.body).to eq('') expect(response.body).to eq('')
end end
end end
......
...@@ -27,7 +27,7 @@ describe Projects::DiscussionsController do ...@@ -27,7 +27,7 @@ describe Projects::DiscussionsController do
it 'returns 404' do it 'returns 404' do
get :show, params: request_params, session: { format: :json } get :show, params: request_params, session: { format: :json }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -39,7 +39,7 @@ describe Projects::DiscussionsController do ...@@ -39,7 +39,7 @@ describe Projects::DiscussionsController do
it 'returns status 200' do it 'returns status 200' do
get :show, params: request_params, session: { format: :json } get :show, params: request_params, session: { format: :json }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'returns status 404 if MR does not exists' do it 'returns status 404 if MR does not exists' do
...@@ -47,7 +47,7 @@ describe Projects::DiscussionsController do ...@@ -47,7 +47,7 @@ describe Projects::DiscussionsController do
get :show, params: request_params, session: { format: :json } get :show, params: request_params, session: { format: :json }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -60,7 +60,7 @@ describe Projects::DiscussionsController do ...@@ -60,7 +60,7 @@ describe Projects::DiscussionsController do
it 'returns status 200' do it 'returns status 200' do
get :show, params: request_params, session: { format: :json } get :show, params: request_params, session: { format: :json }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -74,7 +74,7 @@ describe Projects::DiscussionsController do ...@@ -74,7 +74,7 @@ describe Projects::DiscussionsController do
it "returns status 404" do it "returns status 404" do
post :resolve, params: request_params post :resolve, params: request_params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -91,7 +91,7 @@ describe Projects::DiscussionsController do ...@@ -91,7 +91,7 @@ describe Projects::DiscussionsController do
it "returns status 404" do it "returns status 404" do
post :resolve, params: request_params post :resolve, params: request_params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -120,7 +120,7 @@ describe Projects::DiscussionsController do ...@@ -120,7 +120,7 @@ describe Projects::DiscussionsController do
it "returns status 200" do it "returns status 200" do
post :resolve, params: request_params post :resolve, params: request_params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it "renders discussion with serializer" do it "renders discussion with serializer" do
...@@ -157,7 +157,7 @@ describe Projects::DiscussionsController do ...@@ -157,7 +157,7 @@ describe Projects::DiscussionsController do
it "returns status 404" do it "returns status 404" do
delete :unresolve, params: request_params delete :unresolve, params: request_params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -174,7 +174,7 @@ describe Projects::DiscussionsController do ...@@ -174,7 +174,7 @@ describe Projects::DiscussionsController do
it "returns status 404" do it "returns status 404" do
delete :unresolve, params: request_params delete :unresolve, params: request_params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -188,7 +188,7 @@ describe Projects::DiscussionsController do ...@@ -188,7 +188,7 @@ describe Projects::DiscussionsController do
it "returns status 200" do it "returns status 200" do
delete :unresolve, params: request_params delete :unresolve, params: request_params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
context "when vue_mr_discussions cookie is present" do context "when vue_mr_discussions cookie is present" do
......
...@@ -179,7 +179,7 @@ describe Projects::EnvironmentsController do ...@@ -179,7 +179,7 @@ describe Projects::EnvironmentsController do
params[:id] = 12345 params[:id] = 12345
get :show, params: params get :show, params: params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -197,7 +197,7 @@ describe Projects::EnvironmentsController do ...@@ -197,7 +197,7 @@ describe Projects::EnvironmentsController do
patch_params = environment_params.merge(environment: { external_url: 'https://git.gitlab.com' }) patch_params = environment_params.merge(environment: { external_url: 'https://git.gitlab.com' })
patch :update, params: patch_params patch :update, params: patch_params
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -208,7 +208,7 @@ describe Projects::EnvironmentsController do ...@@ -208,7 +208,7 @@ describe Projects::EnvironmentsController do
patch :stop, params: environment_params(format: :json) patch :stop, params: environment_params(format: :json)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -221,7 +221,7 @@ describe Projects::EnvironmentsController do ...@@ -221,7 +221,7 @@ describe Projects::EnvironmentsController do
patch :stop, params: environment_params(format: :json) patch :stop, params: environment_params(format: :json)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq( expect(json_response).to eq(
{ 'redirect_url' => { 'redirect_url' =>
project_job_url(project, action) }) project_job_url(project, action) })
...@@ -235,7 +235,7 @@ describe Projects::EnvironmentsController do ...@@ -235,7 +235,7 @@ describe Projects::EnvironmentsController do
patch :stop, params: environment_params(format: :json) patch :stop, params: environment_params(format: :json)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq( expect(json_response).to eq(
{ 'redirect_url' => { 'redirect_url' =>
project_environment_url(project, environment) }) project_environment_url(project, environment) })
...@@ -278,7 +278,7 @@ describe Projects::EnvironmentsController do ...@@ -278,7 +278,7 @@ describe Projects::EnvironmentsController do
it 'responds with a status code 200' do it 'responds with a status code 200' do
get :terminal, params: environment_params get :terminal, params: environment_params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'loads the terminals for the environment' do it 'loads the terminals for the environment' do
...@@ -295,7 +295,7 @@ describe Projects::EnvironmentsController do ...@@ -295,7 +295,7 @@ describe Projects::EnvironmentsController do
it 'responds with a status code 404' do it 'responds with a status code 404' do
get :terminal, params: environment_params(id: 666) get :terminal, params: environment_params(id: 666)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -321,7 +321,7 @@ describe Projects::EnvironmentsController do ...@@ -321,7 +321,7 @@ describe Projects::EnvironmentsController do
get :terminal_websocket_authorize, params: environment_params get :terminal_websocket_authorize, params: environment_params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers["Content-Type"]).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.headers["Content-Type"]).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(response.body).to eq('{"workhorse":"response"}') expect(response.body).to eq('{"workhorse":"response"}')
end end
...@@ -331,7 +331,7 @@ describe Projects::EnvironmentsController do ...@@ -331,7 +331,7 @@ describe Projects::EnvironmentsController do
it 'returns 404' do it 'returns 404' do
get :terminal_websocket_authorize, params: environment_params(id: 666) get :terminal_websocket_authorize, params: environment_params(id: 666)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -386,7 +386,7 @@ describe Projects::EnvironmentsController do ...@@ -386,7 +386,7 @@ describe Projects::EnvironmentsController do
get :metrics, params: environment_params(format: :json) get :metrics, params: environment_params(format: :json)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(json_response).to eq({}) expect(json_response).to eq({})
end end
end end
...@@ -428,7 +428,7 @@ describe Projects::EnvironmentsController do ...@@ -428,7 +428,7 @@ describe Projects::EnvironmentsController do
it 'returns a metrics JSON document' do it 'returns a metrics JSON document' do
additional_metrics(window_params) additional_metrics(window_params)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(json_response).to eq({}) expect(json_response).to eq({})
end end
end end
......
...@@ -23,7 +23,7 @@ describe Projects::ForksController do ...@@ -23,7 +23,7 @@ describe Projects::ForksController do
it 'returns with 404' do it 'returns with 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -167,7 +167,7 @@ describe Projects::ForksController do ...@@ -167,7 +167,7 @@ describe Projects::ForksController do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -205,7 +205,7 @@ describe Projects::ForksController do ...@@ -205,7 +205,7 @@ describe Projects::ForksController do
it 'responds with status 302' do it 'responds with status 302' do
subject subject
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_import_path(user.namespace, project)) expect(response).to redirect_to(namespace_project_import_path(user.namespace, project))
end end
...@@ -228,7 +228,7 @@ describe Projects::ForksController do ...@@ -228,7 +228,7 @@ describe Projects::ForksController do
it 'passes continue params to the redirect' do it 'passes continue params to the redirect' do
subject subject
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_import_path(user.namespace, project, continue: continue_params)) expect(response).to redirect_to(namespace_project_import_path(user.namespace, project, continue: continue_params))
end end
end end
......
...@@ -33,7 +33,7 @@ describe Projects::GroupLinksController do ...@@ -33,7 +33,7 @@ describe Projects::GroupLinksController do
include_context 'link project to group' include_context 'link project to group'
it 'responds with status 404' do it 'responds with status 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -42,7 +42,7 @@ describe Projects::HooksController do ...@@ -42,7 +42,7 @@ describe Projects::HooksController do
post :create, params: { namespace_id: project.namespace, project_id: project, hook: hook_params } post :create, params: { namespace_id: project.namespace, project_id: project, hook: hook_params }
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(ProjectHook.all.size).to eq(1) expect(ProjectHook.all.size).to eq(1)
expect(ProjectHook.first).to have_attributes(hook_params) expect(ProjectHook.first).to have_attributes(hook_params)
end end
......
...@@ -24,7 +24,7 @@ describe Projects::IssuesController do ...@@ -24,7 +24,7 @@ describe Projects::IssuesController do
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -32,7 +32,7 @@ describe Projects::IssuesController do ...@@ -32,7 +32,7 @@ describe Projects::IssuesController do
it 'renders the "index" template' do it 'renders the "index" template' do
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index) expect(response).to render_template(:index)
end end
end end
...@@ -51,14 +51,14 @@ describe Projects::IssuesController do ...@@ -51,14 +51,14 @@ describe Projects::IssuesController do
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to redirect_to(project_issues_path(new_project)) expect(response).to redirect_to(project_issues_path(new_project))
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
it 'redirects from an old issue correctly' do it 'redirects from an old issue correctly' do
get :show, params: { namespace_id: project.namespace, project_id: project, id: issue } get :show, params: { namespace_id: project.namespace, project_id: project, id: issue }
expect(response).to redirect_to(project_issue_path(new_project, issue)) expect(response).to redirect_to(project_issue_path(new_project, issue))
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -78,7 +78,7 @@ describe Projects::IssuesController do ...@@ -78,7 +78,7 @@ describe Projects::IssuesController do
it "returns index" do it "returns index" do
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it "returns 301 if request path doesn't match project path" do it "returns 301 if request path doesn't match project path" do
...@@ -92,7 +92,7 @@ describe Projects::IssuesController do ...@@ -92,7 +92,7 @@ describe Projects::IssuesController do
project.save! project.save!
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -118,7 +118,7 @@ describe Projects::IssuesController do ...@@ -118,7 +118,7 @@ describe Projects::IssuesController do
get :index, params: params.merge(page: last_page + 1) get :index, params: params.merge(page: last_page + 1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:issues).size).to eq(2) expect(assigns(:issues).size).to eq(2)
end end
end end
...@@ -227,7 +227,7 @@ describe Projects::IssuesController do ...@@ -227,7 +227,7 @@ describe Projects::IssuesController do
get :new, params: { namespace_id: project.namespace, project_id: project } get :new, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -235,7 +235,7 @@ describe Projects::IssuesController do ...@@ -235,7 +235,7 @@ describe Projects::IssuesController do
it 'renders the "new" template' do it 'renders the "new" template' do
get :new, params: { namespace_id: project.namespace, project_id: project } get :new, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:new) expect(response).to render_template(:new)
end end
end end
...@@ -330,7 +330,7 @@ describe Projects::IssuesController do ...@@ -330,7 +330,7 @@ describe Projects::IssuesController do
[issue1, issue2, issue3].map(&:reload) [issue1, issue2, issue3].map(&:reload)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(issue1.relative_position) expect(issue1.relative_position)
.to be_between(issue2.relative_position, issue3.relative_position) .to be_between(issue2.relative_position, issue3.relative_position)
end end
...@@ -340,7 +340,7 @@ describe Projects::IssuesController do ...@@ -340,7 +340,7 @@ describe Projects::IssuesController do
it 'returns a unprocessable entity 422 response for invalid move ids' do it 'returns a unprocessable entity 422 response for invalid move ids' do
reorder_issue(issue1, move_after_id: 99, move_before_id: 999) reorder_issue(issue1, move_after_id: 99, move_before_id: 999)
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
it 'returns a not found 404 response for invalid issue id' do it 'returns a not found 404 response for invalid issue id' do
...@@ -348,7 +348,7 @@ describe Projects::IssuesController do ...@@ -348,7 +348,7 @@ describe Projects::IssuesController do
move_after_id: issue2.id, move_after_id: issue2.id,
move_before_id: issue3.id) move_before_id: issue3.id)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a unprocessable entity 422 response for issues not in group' do it 'returns a unprocessable entity 422 response for issues not in group' do
...@@ -359,7 +359,7 @@ describe Projects::IssuesController do ...@@ -359,7 +359,7 @@ describe Projects::IssuesController do
move_before_id: issue3.id, move_before_id: issue3.id,
group_full_path: another_group.full_path) group_full_path: another_group.full_path)
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
end end
...@@ -415,7 +415,7 @@ describe Projects::IssuesController do ...@@ -415,7 +415,7 @@ describe Projects::IssuesController do
it 'updates the issue' do it 'updates the issue' do
subject subject
expect(response).to have_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(issue.reload.title).to eq('New title') expect(issue.reload.title).to eq('New title')
end end
...@@ -443,7 +443,7 @@ describe Projects::IssuesController do ...@@ -443,7 +443,7 @@ describe Projects::IssuesController do
it 'updates the issue' do it 'updates the issue' do
subject subject
expect(response).to have_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(issue.reload.title).to eq('New title') expect(issue.reload.title).to eq('New title')
end end
end end
...@@ -458,7 +458,7 @@ describe Projects::IssuesController do ...@@ -458,7 +458,7 @@ describe Projects::IssuesController do
it 'responds with 404' do it 'responds with 404' do
subject subject
expect(response).to have_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -505,7 +505,7 @@ describe Projects::IssuesController do ...@@ -505,7 +505,7 @@ describe Projects::IssuesController do
it 'returns 200' do it 'returns 200' do
go(id: issue.iid) go(id: issue.iid)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -749,7 +749,7 @@ describe Projects::IssuesController do ...@@ -749,7 +749,7 @@ describe Projects::IssuesController do
it 'returns 200 status' do it 'returns 200 status' do
update_issue update_issue
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -769,7 +769,7 @@ describe Projects::IssuesController do ...@@ -769,7 +769,7 @@ describe Projects::IssuesController do
it 'returns 200 status' do it 'returns 200 status' do
update_issue update_issue
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -785,7 +785,7 @@ describe Projects::IssuesController do ...@@ -785,7 +785,7 @@ describe Projects::IssuesController do
end end
it 'returns 200 status' do it 'returns 200 status' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'accepts an issue after recaptcha is verified' do it 'accepts an issue after recaptcha is verified' do
...@@ -1131,7 +1131,7 @@ describe Projects::IssuesController do ...@@ -1131,7 +1131,7 @@ describe Projects::IssuesController do
it "rejects a developer to destroy an issue" do it "rejects a developer to destroy an issue" do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -1147,14 +1147,14 @@ describe Projects::IssuesController do ...@@ -1147,14 +1147,14 @@ describe Projects::IssuesController do
it "deletes the issue" do it "deletes the issue" do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, destroy_confirm: true } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, destroy_confirm: true }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./) expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./)
end end
it "deletes the issue" do it "deletes the issue" do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, destroy_confirm: true } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, destroy_confirm: true }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./) expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./)
end end
...@@ -1163,7 +1163,7 @@ describe Projects::IssuesController do ...@@ -1163,7 +1163,7 @@ describe Projects::IssuesController do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:notice].to('Destroy confirmation not provided for issue') expect(controller).to set_flash[:notice].to('Destroy confirmation not provided for issue')
end end
...@@ -1172,7 +1172,7 @@ describe Projects::IssuesController do ...@@ -1172,7 +1172,7 @@ describe Projects::IssuesController do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, format: 'json' } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid, format: 'json' }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response).to eq({ 'errors' => 'Destroy confirmation not provided for issue' }) expect(json_response).to eq({ 'errors' => 'Destroy confirmation not provided for issue' })
end end
...@@ -1206,7 +1206,7 @@ describe Projects::IssuesController do ...@@ -1206,7 +1206,7 @@ describe Projects::IssuesController do
subject subject
end.to change { issue.award_emoji.count }.by(1) end.to change { issue.award_emoji.count }.by(1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it "removes the already awarded emoji" do it "removes the already awarded emoji" do
...@@ -1214,7 +1214,7 @@ describe Projects::IssuesController do ...@@ -1214,7 +1214,7 @@ describe Projects::IssuesController do
expect { subject }.to change { AwardEmoji.count }.by(-1) expect { subject }.to change { AwardEmoji.count }.by(-1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'marks Todos on the Issue as done' do it 'marks Todos on the Issue as done' do
...@@ -1250,7 +1250,7 @@ describe Projects::IssuesController do ...@@ -1250,7 +1250,7 @@ describe Projects::IssuesController do
create_merge_request create_merge_request
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'is not available for users who cannot create merge requests' do it 'is not available for users who cannot create merge requests' do
...@@ -1258,7 +1258,7 @@ describe Projects::IssuesController do ...@@ -1258,7 +1258,7 @@ describe Projects::IssuesController do
create_merge_request create_merge_request
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context 'target_project_id is set' do context 'target_project_id is set' do
......
...@@ -1183,7 +1183,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -1183,7 +1183,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
get_terminal_websocket(id: job.id) get_terminal_websocket(id: job.id)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.headers["Content-Type"]).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.headers["Content-Type"]).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
expect(response.body).to eq('{"workhorse":"response"}') expect(response.body).to eq('{"workhorse":"response"}')
end end
...@@ -1193,7 +1193,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do ...@@ -1193,7 +1193,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
it 'returns 404' do it 'returns 404' do
get_terminal_websocket(id: 1234) get_terminal_websocket(id: 1234)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -80,7 +80,7 @@ describe Projects::LabelsController do ...@@ -80,7 +80,7 @@ describe Projects::LabelsController do
it 'creates labels' do it 'creates labels' do
post :generate, params: { namespace_id: personal_project.namespace.to_param, project_id: personal_project } post :generate, params: { namespace_id: personal_project.namespace.to_param, project_id: personal_project }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -88,7 +88,7 @@ describe Projects::LabelsController do ...@@ -88,7 +88,7 @@ describe Projects::LabelsController do
it 'creates labels' do it 'creates labels' do
post :generate, params: { namespace_id: project.namespace.to_param, project_id: project } post :generate, params: { namespace_id: project.namespace.to_param, project_id: project }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -99,7 +99,7 @@ describe Projects::LabelsController do ...@@ -99,7 +99,7 @@ describe Projects::LabelsController do
toggle_subscription(label) toggle_subscription(label)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'allows user to toggle subscription on group labels' do it 'allows user to toggle subscription on group labels' do
...@@ -107,7 +107,7 @@ describe Projects::LabelsController do ...@@ -107,7 +107,7 @@ describe Projects::LabelsController do
toggle_subscription(group_label) toggle_subscription(group_label)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
def toggle_subscription(label) def toggle_subscription(label)
...@@ -123,7 +123,7 @@ describe Projects::LabelsController do ...@@ -123,7 +123,7 @@ describe Projects::LabelsController do
it 'denies access' do it 'denies access' do
post :promote, params: { namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param } post :promote, params: { namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -180,7 +180,7 @@ describe Projects::LabelsController do ...@@ -180,7 +180,7 @@ describe Projects::LabelsController do
it 'does not redirect' do it 'does not redirect' do
get :index, params: { namespace_id: project.namespace, project_id: project.to_param } get :index, params: { namespace_id: project.namespace, project_id: project.to_param }
expect(response).not_to have_gitlab_http_status(301) expect(response).not_to have_gitlab_http_status(:moved_permanently)
end end
end end
...@@ -231,13 +231,13 @@ describe Projects::LabelsController do ...@@ -231,13 +231,13 @@ describe Projects::LabelsController do
it 'does not 404' do it 'does not 404' do
post :generate, params: { namespace_id: project.namespace, project_id: project } post :generate, params: { namespace_id: project.namespace, project_id: project }
expect(response).not_to have_gitlab_http_status(404) expect(response).not_to have_gitlab_http_status(:not_found)
end end
it 'does not redirect to the correct casing' do it 'does not redirect to the correct casing' do
post :generate, params: { namespace_id: project.namespace, project_id: project } post :generate, params: { namespace_id: project.namespace, project_id: project }
expect(response).not_to have_gitlab_http_status(301) expect(response).not_to have_gitlab_http_status(:moved_permanently)
end end
end end
...@@ -247,7 +247,7 @@ describe Projects::LabelsController do ...@@ -247,7 +247,7 @@ describe Projects::LabelsController do
it 'returns not found' do it 'returns not found' do
post :generate, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' } post :generate, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -25,7 +25,7 @@ describe Projects::MattermostsController do ...@@ -25,7 +25,7 @@ describe Projects::MattermostsController do
project_id: project project_id: project
}) })
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
......
...@@ -113,7 +113,7 @@ describe Projects::MergeRequestsController do ...@@ -113,7 +113,7 @@ describe Projects::MergeRequestsController do
} }
expect(response).to redirect_to(project_merge_request_path(new_project, merge_request)) expect(response).to redirect_to(project_merge_request_path(new_project, merge_request))
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
it 'redirects from an old merge request commits correctly' do it 'redirects from an old merge request commits correctly' do
...@@ -125,7 +125,7 @@ describe Projects::MergeRequestsController do ...@@ -125,7 +125,7 @@ describe Projects::MergeRequestsController do
} }
expect(response).to redirect_to(commits_project_merge_request_path(new_project, merge_request)) expect(response).to redirect_to(commits_project_merge_request_path(new_project, merge_request))
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -229,7 +229,7 @@ describe Projects::MergeRequestsController do ...@@ -229,7 +229,7 @@ describe Projects::MergeRequestsController do
get_merge_requests(last_page) get_merge_requests(last_page)
expect(assigns(:merge_requests).current_page).to eq(last_page) expect(assigns(:merge_requests).current_page).to eq(last_page)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'does not redirect to external sites when provided a host field' do it 'does not redirect to external sites when provided a host field' do
...@@ -306,7 +306,7 @@ describe Projects::MergeRequestsController do ...@@ -306,7 +306,7 @@ describe Projects::MergeRequestsController do
it 'responds with 404' do it 'responds with 404' do
update_merge_request(title: 'New title') update_merge_request(title: 'New title')
expect(response).to have_http_status(:not_found) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -381,7 +381,7 @@ describe Projects::MergeRequestsController do ...@@ -381,7 +381,7 @@ describe Projects::MergeRequestsController do
end end
it 'returns 404' do it 'returns 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -615,7 +615,7 @@ describe Projects::MergeRequestsController do ...@@ -615,7 +615,7 @@ describe Projects::MergeRequestsController do
it "denies access to users unless they're admin or project owner" do it "denies access to users unless they're admin or project owner" do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
context "when the user is owner" do context "when the user is owner" do
...@@ -630,7 +630,7 @@ describe Projects::MergeRequestsController do ...@@ -630,7 +630,7 @@ describe Projects::MergeRequestsController do
it "deletes the merge request" do it "deletes the merge request" do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid, destroy_confirm: true } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid, destroy_confirm: true }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:notice].to(/The merge request was successfully deleted\./) expect(controller).to set_flash[:notice].to(/The merge request was successfully deleted\./)
end end
...@@ -639,7 +639,7 @@ describe Projects::MergeRequestsController do ...@@ -639,7 +639,7 @@ describe Projects::MergeRequestsController do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(controller).to set_flash[:notice].to('Destroy confirmation not provided for merge request') expect(controller).to set_flash[:notice].to('Destroy confirmation not provided for merge request')
end end
...@@ -648,7 +648,7 @@ describe Projects::MergeRequestsController do ...@@ -648,7 +648,7 @@ describe Projects::MergeRequestsController do
delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid, format: 'json' } delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid, format: 'json' }
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
expect(json_response).to eq({ 'errors' => 'Destroy confirmation not provided for merge request' }) expect(json_response).to eq({ 'errors' => 'Destroy confirmation not provided for merge request' })
end end
...@@ -842,7 +842,7 @@ describe Projects::MergeRequestsController do ...@@ -842,7 +842,7 @@ describe Projects::MergeRequestsController do
it 'responds with a 404' do it 'responds with a 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to be_blank expect(response.body).to be_blank
end end
end end
...@@ -855,7 +855,7 @@ describe Projects::MergeRequestsController do ...@@ -855,7 +855,7 @@ describe Projects::MergeRequestsController do
it 'responds with a 404' do it 'responds with a 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to be_blank expect(response.body).to be_blank
end end
end end
...@@ -898,7 +898,7 @@ describe Projects::MergeRequestsController do ...@@ -898,7 +898,7 @@ describe Projects::MergeRequestsController do
it 'returns exposed artifacts' do it 'returns exposed artifacts' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('parsed') expect(json_response['status']).to eq('parsed')
expect(json_response['data']).to eq([{ expect(json_response['data']).to eq([{
'job_name' => 'test', 'job_name' => 'test',
...@@ -951,7 +951,7 @@ describe Projects::MergeRequestsController do ...@@ -951,7 +951,7 @@ describe Projects::MergeRequestsController do
it 'returns no content' do it 'returns no content' do
subject subject
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(response.body).to be_empty expect(response.body).to be_empty
end end
end end
...@@ -998,7 +998,7 @@ describe Projects::MergeRequestsController do ...@@ -998,7 +998,7 @@ describe Projects::MergeRequestsController do
it 'responds with a 404' do it 'responds with a 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to be_blank expect(response.body).to be_blank
end end
end end
...@@ -1011,7 +1011,7 @@ describe Projects::MergeRequestsController do ...@@ -1011,7 +1011,7 @@ describe Projects::MergeRequestsController do
it 'responds with a 404' do it 'responds with a 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to be_blank expect(response.body).to be_blank
end end
end end
......
...@@ -30,14 +30,14 @@ describe Projects::MilestonesController do ...@@ -30,14 +30,14 @@ describe Projects::MilestonesController do
it 'shows milestone page' do it 'shows milestone page' do
view_milestone view_milestone
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'text/html' expect(response.content_type).to eq 'text/html'
end end
it 'returns milestone json' do it 'returns milestone json' do
view_milestone format: :json view_milestone format: :json
expect(response).to have_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
end end
end end
...@@ -171,7 +171,7 @@ describe Projects::MilestonesController do ...@@ -171,7 +171,7 @@ describe Projects::MilestonesController do
it 'renders 404' do it 'renders 404' do
post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid } post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -190,7 +190,7 @@ describe Projects::MilestonesController do ...@@ -190,7 +190,7 @@ describe Projects::MilestonesController do
get :labels, params: { namespace_id: group.id, project_id: project.id, id: milestone.iid }, format: :json get :labels, params: { namespace_id: group.id, project_id: project.id, id: milestone.iid }, format: :json
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['html']).not_to include(label.title) expect(json_response['html']).not_to include(label.title)
...@@ -201,7 +201,7 @@ describe Projects::MilestonesController do ...@@ -201,7 +201,7 @@ describe Projects::MilestonesController do
get :labels, params: { namespace_id: group.id, project_id: project.id, id: milestone.iid }, format: :json get :labels, params: { namespace_id: group.id, project_id: project.id, id: milestone.iid }, format: :json
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['html']).to include(label.title) expect(json_response['html']).to include(label.title)
...@@ -240,7 +240,7 @@ describe Projects::MilestonesController do ...@@ -240,7 +240,7 @@ describe Projects::MilestonesController do
post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid } post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -263,7 +263,7 @@ describe Projects::MilestonesController do ...@@ -263,7 +263,7 @@ describe Projects::MilestonesController do
params = { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :json } params = { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :json }
get :participants, params: params get :participants, params: params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['html']).to include(issue_assignee.name) expect(json_response['html']).to include(issue_assignee.name)
end end
...@@ -278,7 +278,7 @@ describe Projects::MilestonesController do ...@@ -278,7 +278,7 @@ describe Projects::MilestonesController do
params = { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :json } params = { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid, format: :json }
get :participants, params: params get :participants, params: params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.content_type).to eq 'application/json' expect(response.content_type).to eq 'application/json'
expect(json_response['html']).not_to include(issue_assignee.name) expect(json_response['html']).not_to include(issue_assignee.name)
end end
......
...@@ -103,7 +103,7 @@ describe Projects::MirrorsController do ...@@ -103,7 +103,7 @@ describe Projects::MirrorsController do
it "returns an error with a 400 response for URL #{url.inspect}" do it "returns an error with a 400 response for URL #{url.inspect}" do
do_get(project, url) do_get(project, url)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq('message' => 'Invalid URL') expect(json_response).to eq('message' => 'Invalid URL')
end end
end end
...@@ -115,7 +115,7 @@ describe Projects::MirrorsController do ...@@ -115,7 +115,7 @@ describe Projects::MirrorsController do
do_get(project) do_get(project)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
end end
...@@ -125,7 +125,7 @@ describe Projects::MirrorsController do ...@@ -125,7 +125,7 @@ describe Projects::MirrorsController do
do_get(project) do_get(project)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to eq('message' => 'An error') expect(json_response).to eq('message' => 'An error')
end end
end end
...@@ -139,7 +139,7 @@ describe Projects::MirrorsController do ...@@ -139,7 +139,7 @@ describe Projects::MirrorsController do
do_get(project) do_get(project)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq('known_hosts' => ssh_key, 'fingerprints' => [ssh_fp.stringify_keys], 'host_keys_changed' => true) expect(json_response).to eq('known_hosts' => ssh_key, 'fingerprints' => [ssh_fp.stringify_keys], 'host_keys_changed' => true)
end end
end end
......
...@@ -23,7 +23,7 @@ describe Projects::PagesController do ...@@ -23,7 +23,7 @@ describe Projects::PagesController do
it 'returns 200 status' do it 'returns 200 status' do
get :show, params: request_params get :show, params: request_params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
context 'when the project is in a subgroup' do context 'when the project is in a subgroup' do
...@@ -33,7 +33,7 @@ describe Projects::PagesController do ...@@ -33,7 +33,7 @@ describe Projects::PagesController do
it 'returns a 200 status code' do it 'returns a 200 status code' do
get :show, params: request_params get :show, params: request_params
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -42,7 +42,7 @@ describe Projects::PagesController do ...@@ -42,7 +42,7 @@ describe Projects::PagesController do
it 'returns 302 status' do it 'returns 302 status' do
delete :destroy, params: request_params delete :destroy, params: request_params
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
context 'when user is developer' do context 'when user is developer' do
...@@ -53,7 +53,7 @@ describe Projects::PagesController do ...@@ -53,7 +53,7 @@ describe Projects::PagesController do
it 'returns 404 status' do it 'returns 404 status' do
delete :destroy, params: request_params delete :destroy, params: request_params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -67,7 +67,7 @@ describe Projects::PagesController do ...@@ -67,7 +67,7 @@ describe Projects::PagesController do
it 'returns 404 status' do it 'returns 404 status' do
get :show, params: request_params get :show, params: request_params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -75,7 +75,7 @@ describe Projects::PagesController do ...@@ -75,7 +75,7 @@ describe Projects::PagesController do
it 'returns 404 status' do it 'returns 404 status' do
delete :destroy, params: request_params delete :destroy, params: request_params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -35,7 +35,7 @@ describe Projects::PagesDomainsController do ...@@ -35,7 +35,7 @@ describe Projects::PagesDomainsController do
it "displays to the 'show' page" do it "displays to the 'show' page" do
make_request make_request
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('show') expect(response).to render_template('show')
end end
...@@ -47,7 +47,7 @@ describe Projects::PagesDomainsController do ...@@ -47,7 +47,7 @@ describe Projects::PagesDomainsController do
it 'renders 404 page' do it 'renders 404 page' do
make_request make_request
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -56,7 +56,7 @@ describe Projects::PagesDomainsController do ...@@ -56,7 +56,7 @@ describe Projects::PagesDomainsController do
it "displays the 'new' page" do it "displays the 'new' page" do
get(:new, params: request_params) get(:new, params: request_params)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('new') expect(response).to render_template('new')
end end
end end
...@@ -78,7 +78,7 @@ describe Projects::PagesDomainsController do ...@@ -78,7 +78,7 @@ describe Projects::PagesDomainsController do
it "displays the 'show' page" do it "displays the 'show' page" do
get(:show, params: request_params.merge(id: pages_domain.domain)) get(:show, params: request_params.merge(id: pages_domain.domain))
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template('show') expect(response).to render_template('show')
end end
end end
...@@ -177,7 +177,7 @@ describe Projects::PagesDomainsController do ...@@ -177,7 +177,7 @@ describe Projects::PagesDomainsController do
it 'returns a 404 response for an unknown domain' do it 'returns a 404 response for an unknown domain' do
post :verify, params: request_params.merge(id: 'unknown-domain') post :verify, params: request_params.merge(id: 'unknown-domain')
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -250,7 +250,7 @@ describe Projects::PagesDomainsController do ...@@ -250,7 +250,7 @@ describe Projects::PagesDomainsController do
it 'returns 404 status' do it 'returns 404 status' do
get(:show, params: request_params.merge(id: pages_domain.domain)) get(:show, params: request_params.merge(id: pages_domain.domain))
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -258,7 +258,7 @@ describe Projects::PagesDomainsController do ...@@ -258,7 +258,7 @@ describe Projects::PagesDomainsController do
it 'returns 404 status' do it 'returns 404 status' do
get :new, params: request_params get :new, params: request_params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -266,7 +266,7 @@ describe Projects::PagesDomainsController do ...@@ -266,7 +266,7 @@ describe Projects::PagesDomainsController do
it "returns 404 status" do it "returns 404 status" do
post(:create, params: request_params.merge(pages_domain: pages_domain_params)) post(:create, params: request_params.merge(pages_domain: pages_domain_params))
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -274,7 +274,7 @@ describe Projects::PagesDomainsController do ...@@ -274,7 +274,7 @@ describe Projects::PagesDomainsController do
it "deletes the pages domain" do it "deletes the pages domain" do
delete(:destroy, params: request_params.merge(id: pages_domain.domain)) delete(:destroy, params: request_params.merge(id: pages_domain.domain))
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -396,7 +396,7 @@ describe Projects::PipelineSchedulesController do ...@@ -396,7 +396,7 @@ describe Projects::PipelineSchedulesController do
post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id } post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -407,7 +407,7 @@ describe Projects::PipelineSchedulesController do ...@@ -407,7 +407,7 @@ describe Projects::PipelineSchedulesController do
post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id } post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
expect(flash[:notice]).to start_with 'Successfully scheduled a pipeline to run' expect(flash[:notice]).to start_with 'Successfully scheduled a pipeline to run'
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
it 'prevents users from scheduling the same pipeline repeatedly' do it 'prevents users from scheduling the same pipeline repeatedly' do
...@@ -417,7 +417,7 @@ describe Projects::PipelineSchedulesController do ...@@ -417,7 +417,7 @@ describe Projects::PipelineSchedulesController do
expect(flash.to_a.size).to eq(2) expect(flash.to_a.size).to eq(2)
expect(flash[:alert]).to eq _('You cannot play this scheduled pipeline at the moment. Please wait a minute.') expect(flash[:alert]).to eq _('You cannot play this scheduled pipeline at the moment. Please wait a minute.')
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -430,7 +430,7 @@ describe Projects::PipelineSchedulesController do ...@@ -430,7 +430,7 @@ describe Projects::PipelineSchedulesController do
post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: protected_schedule.id } post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: protected_schedule.id }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -460,7 +460,7 @@ describe Projects::PipelineSchedulesController do ...@@ -460,7 +460,7 @@ describe Projects::PipelineSchedulesController do
delete :destroy, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id } delete :destroy, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
end.to change { project.pipeline_schedules.count }.by(-1) end.to change { project.pipeline_schedules.count }.by(-1)
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
......
...@@ -703,7 +703,7 @@ describe Projects::PipelinesController do ...@@ -703,7 +703,7 @@ describe Projects::PipelinesController do
it 'shows latest pipeline for the default project branch' do it 'shows latest pipeline for the default project branch' do
get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: nil } get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: nil }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:pipeline)).to have_attributes(id: pipeline_master.id) expect(assigns(:pipeline)).to have_attributes(id: pipeline_master.id)
end end
end end
...@@ -716,7 +716,7 @@ describe Projects::PipelinesController do ...@@ -716,7 +716,7 @@ describe Projects::PipelinesController do
it 'shows the latest pipeline for the provided ref' do it 'shows the latest pipeline for the provided ref' do
get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: branch_secondary.name } get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: branch_secondary.name }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:pipeline)).to have_attributes(id: pipeline_secondary.id) expect(assigns(:pipeline)).to have_attributes(id: pipeline_secondary.id)
end end
...@@ -728,7 +728,7 @@ describe Projects::PipelinesController do ...@@ -728,7 +728,7 @@ describe Projects::PipelinesController do
it 'shows the provided ref with the last sha/pipeline combo' do it 'shows the provided ref with the last sha/pipeline combo' do
get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: branch_secondary.name } get :show, params: { namespace_id: project.namespace, project_id: project, latest: true, ref: branch_secondary.name }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:pipeline)).to have_attributes(id: pipeline_secondary.id) expect(assigns(:pipeline)).to have_attributes(id: pipeline_secondary.id)
end end
end end
...@@ -737,7 +737,7 @@ describe Projects::PipelinesController do ...@@ -737,7 +737,7 @@ describe Projects::PipelinesController do
it 'renders a 404 if no pipeline is found for the ref' do it 'renders a 404 if no pipeline is found for the ref' do
get :show, params: { namespace_id: project.namespace, project_id: project, ref: 'no-branch' } get :show, params: { namespace_id: project.namespace, project_id: project, ref: 'no-branch' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -754,7 +754,7 @@ describe Projects::PipelinesController do ...@@ -754,7 +754,7 @@ describe Projects::PipelinesController do
it 'deletes pipeline and redirects' do it 'deletes pipeline and redirects' do
delete_pipeline delete_pipeline
expect(response).to have_gitlab_http_status(303) expect(response).to have_gitlab_http_status(:see_other)
expect(Ci::Build.exists?(build.id)).to be_falsy expect(Ci::Build.exists?(build.id)).to be_falsy
expect(Ci::Pipeline.exists?(pipeline.id)).to be_falsy expect(Ci::Pipeline.exists?(pipeline.id)).to be_falsy
...@@ -766,7 +766,7 @@ describe Projects::PipelinesController do ...@@ -766,7 +766,7 @@ describe Projects::PipelinesController do
it 'fails to delete pipeline' do it 'fails to delete pipeline' do
delete_pipeline delete_pipeline
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -775,7 +775,7 @@ describe Projects::PipelinesController do ...@@ -775,7 +775,7 @@ describe Projects::PipelinesController do
it 'fails to delete pipeline' do it 'fails to delete pipeline' do
delete_pipeline delete_pipeline
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
......
...@@ -17,7 +17,7 @@ describe Projects::PipelinesSettingsController do ...@@ -17,7 +17,7 @@ describe Projects::PipelinesSettingsController do
it 'redirects with 302 status code' do it 'redirects with 302 status code' do
get :show, params: { namespace_id: project.namespace, project_id: project } get :show, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -11,7 +11,7 @@ describe Projects::ProjectMembersController do ...@@ -11,7 +11,7 @@ describe Projects::ProjectMembersController do
it 'has the project_members address with a 200 status code' do it 'has the project_members address with a 200 status code' do
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
context 'when project belongs to group' do context 'when project belongs to group' do
...@@ -64,7 +64,7 @@ describe Projects::ProjectMembersController do ...@@ -64,7 +64,7 @@ describe Projects::ProjectMembersController do
access_level: Gitlab::Access::GUEST access_level: Gitlab::Access::GUEST
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(project.users).not_to include project_user expect(project.users).not_to include project_user
end end
end end
...@@ -145,7 +145,7 @@ describe Projects::ProjectMembersController do ...@@ -145,7 +145,7 @@ describe Projects::ProjectMembersController do
id: 42 id: 42
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -162,7 +162,7 @@ describe Projects::ProjectMembersController do ...@@ -162,7 +162,7 @@ describe Projects::ProjectMembersController do
id: member id: member
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(project.members).to include member expect(project.members).to include member
end end
end end
...@@ -211,7 +211,7 @@ describe Projects::ProjectMembersController do ...@@ -211,7 +211,7 @@ describe Projects::ProjectMembersController do
project_id: project project_id: project
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -246,7 +246,7 @@ describe Projects::ProjectMembersController do ...@@ -246,7 +246,7 @@ describe Projects::ProjectMembersController do
project_id: project project_id: project
} }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -305,7 +305,7 @@ describe Projects::ProjectMembersController do ...@@ -305,7 +305,7 @@ describe Projects::ProjectMembersController do
id: 42 id: 42
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -322,7 +322,7 @@ describe Projects::ProjectMembersController do ...@@ -322,7 +322,7 @@ describe Projects::ProjectMembersController do
id: member id: member
} }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(project.members).not_to include member expect(project.members).not_to include member
end end
end end
......
...@@ -23,7 +23,7 @@ describe Projects::RawController do ...@@ -23,7 +23,7 @@ describe Projects::RawController do
it 'delivers ASCII file' do it 'delivers ASCII file' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
expect(response.header['Content-Disposition']).to eq('inline') expect(response.header['Content-Disposition']).to eq('inline')
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
...@@ -37,7 +37,7 @@ describe Projects::RawController do ...@@ -37,7 +37,7 @@ describe Projects::RawController do
it 'leaves image content disposition' do it 'leaves image content disposition' do
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.header['Content-Disposition']).to eq('inline') expect(response.header['Content-Disposition']).to eq('inline')
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true" expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:') expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
...@@ -63,7 +63,7 @@ describe Projects::RawController do ...@@ -63,7 +63,7 @@ describe Projects::RawController do
.to change { Gitlab::GitalyClient.get_request_count }.by(0) .to change { Gitlab::GitalyClient.get_request_count }.by(0)
expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.')) expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.'))
expect(response).to have_gitlab_http_status(429) expect(response).to have_gitlab_http_status(:too_many_requests)
end end
it 'logs the event on auth.log' do it 'logs the event on auth.log' do
...@@ -94,7 +94,7 @@ describe Projects::RawController do ...@@ -94,7 +94,7 @@ describe Projects::RawController do
request.headers['X-Gitlab-External-Storage-Token'] = token request.headers['X-Gitlab-External-Storage-Token'] = token
execute_raw_requests(requests: 6, project: project, file_path: file_path) execute_raw_requests(requests: 6, project: project, file_path: file_path)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -113,7 +113,7 @@ describe Projects::RawController do ...@@ -113,7 +113,7 @@ describe Projects::RawController do
execute_raw_requests(requests: 3, project: project, file_path: modified_path) execute_raw_requests(requests: 3, project: project, file_path: modified_path)
expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.')) expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.'))
expect(response).to have_gitlab_http_status(429) expect(response).to have_gitlab_http_status(:too_many_requests)
end end
end end
...@@ -125,7 +125,7 @@ describe Projects::RawController do ...@@ -125,7 +125,7 @@ describe Projects::RawController do
it 'does not prevent from accessing the raw file' do it 'does not prevent from accessing the raw file' do
execute_raw_requests(requests: 10, project: project, file_path: file_path) execute_raw_requests(requests: 10, project: project, file_path: file_path)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -141,14 +141,14 @@ describe Projects::RawController do ...@@ -141,14 +141,14 @@ describe Projects::RawController do
execute_raw_requests(requests: 6, project: project, file_path: file_path) execute_raw_requests(requests: 6, project: project, file_path: file_path)
expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.')) expect(response.body).to eq(_('You cannot access the raw file. Please wait a minute.'))
expect(response).to have_gitlab_http_status(429) expect(response).to have_gitlab_http_status(:too_many_requests)
# Accessing upcase version of readme # Accessing upcase version of readme
file_path = "#{commit_sha}/README.md" file_path = "#{commit_sha}/README.md"
execute_raw_requests(requests: 1, project: project, file_path: file_path) execute_raw_requests(requests: 1, project: project, file_path: file_path)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -166,7 +166,7 @@ describe Projects::RawController do ...@@ -166,7 +166,7 @@ describe Projects::RawController do
it 'redirects to sign in page' do it 'redirects to sign in page' do
execute_raw_requests(requests: 1, project: project, file_path: file_path) execute_raw_requests(requests: 1, project: project, file_path: file_path)
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response.location).to end_with('/users/sign_in') expect(response.location).to end_with('/users/sign_in')
end end
end end
...@@ -176,7 +176,7 @@ describe Projects::RawController do ...@@ -176,7 +176,7 @@ describe Projects::RawController do
it 'calls the action normally' do it 'calls the action normally' do
execute_raw_requests(requests: 1, project: project, file_path: file_path, token: user.static_object_token) execute_raw_requests(requests: 1, project: project, file_path: file_path, token: user.static_object_token)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -184,7 +184,7 @@ describe Projects::RawController do ...@@ -184,7 +184,7 @@ describe Projects::RawController do
it 'redirects to sign in page' do it 'redirects to sign in page' do
execute_raw_requests(requests: 1, project: project, file_path: file_path, token: 'foobar') execute_raw_requests(requests: 1, project: project, file_path: file_path, token: 'foobar')
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response.location).to end_with('/users/sign_in') expect(response.location).to end_with('/users/sign_in')
end end
end end
...@@ -196,7 +196,7 @@ describe Projects::RawController do ...@@ -196,7 +196,7 @@ describe Projects::RawController do
request.headers['X-Gitlab-Static-Object-Token'] = user.static_object_token request.headers['X-Gitlab-Static-Object-Token'] = user.static_object_token
execute_raw_requests(requests: 1, project: project, file_path: file_path) execute_raw_requests(requests: 1, project: project, file_path: file_path)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -205,7 +205,7 @@ describe Projects::RawController do ...@@ -205,7 +205,7 @@ describe Projects::RawController do
request.headers['X-Gitlab-Static-Object-Token'] = 'foobar' request.headers['X-Gitlab-Static-Object-Token'] = 'foobar'
execute_raw_requests(requests: 1, project: project, file_path: file_path) execute_raw_requests(requests: 1, project: project, file_path: file_path)
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response.location).to end_with('/users/sign_in') expect(response.location).to end_with('/users/sign_in')
end end
end end
......
...@@ -45,7 +45,7 @@ describe Projects::RepositoriesController do ...@@ -45,7 +45,7 @@ describe Projects::RepositoriesController do
it 'handles legacy queries with the ref specified as ref in params' do it 'handles legacy queries with the ref specified as ref in params' do
get :archive, params: { namespace_id: project.namespace, project_id: project, ref: 'feature' }, format: 'zip' get :archive, params: { namespace_id: project.namespace, project_id: project, ref: 'feature' }, format: 'zip'
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:ref)).to eq('feature') expect(assigns(:ref)).to eq('feature')
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end end
...@@ -53,7 +53,7 @@ describe Projects::RepositoriesController do ...@@ -53,7 +53,7 @@ describe Projects::RepositoriesController do
it 'handles legacy queries with the ref specified as id in params' do it 'handles legacy queries with the ref specified as id in params' do
get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'feature' }, format: 'zip' get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'feature' }, format: 'zip'
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:ref)).to eq('feature') expect(assigns(:ref)).to eq('feature')
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end end
...@@ -61,7 +61,7 @@ describe Projects::RepositoriesController do ...@@ -61,7 +61,7 @@ describe Projects::RepositoriesController do
it 'prioritizes the id param over the ref param when both are specified' do it 'prioritizes the id param over the ref param when both are specified' do
get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'feature', ref: 'feature_conflict' }, format: 'zip' get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'feature', ref: 'feature_conflict' }, format: 'zip'
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:ref)).to eq('feature') expect(assigns(:ref)).to eq('feature')
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end end
...@@ -74,7 +74,7 @@ describe Projects::RepositoriesController do ...@@ -74,7 +74,7 @@ describe Projects::RepositoriesController do
it "renders Not Found" do it "renders Not Found" do
get :archive, params: { namespace_id: project.namespace, project_id: project, id: "master" }, format: "zip" get :archive, params: { namespace_id: project.namespace, project_id: project, id: "master" }, format: "zip"
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -82,7 +82,7 @@ describe Projects::RepositoriesController do ...@@ -82,7 +82,7 @@ describe Projects::RepositoriesController do
it 'sets appropriate caching headers' do it 'sets appropriate caching headers' do
get_archive get_archive
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.header['ETag']).to be_present expect(response.header['ETag']).to be_present
expect(response.header['Cache-Control']).to include('max-age=60, private') expect(response.header['Cache-Control']).to include('max-age=60, private')
end end
...@@ -93,7 +93,7 @@ describe Projects::RepositoriesController do ...@@ -93,7 +93,7 @@ describe Projects::RepositoriesController do
it 'sets appropriate caching headers' do it 'sets appropriate caching headers' do
get_archive get_archive
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.header['ETag']).to be_present expect(response.header['ETag']).to be_present
expect(response.header['Cache-Control']).to include('max-age=60, public') expect(response.header['Cache-Control']).to include('max-age=60, public')
end end
...@@ -103,7 +103,7 @@ describe Projects::RepositoriesController do ...@@ -103,7 +103,7 @@ describe Projects::RepositoriesController do
it 'max-age is set to 3600 in Cache-Control header' do it 'max-age is set to 3600 in Cache-Control header' do
get_archive('ddd0f15ae83993f5cb66a927a28673882e99100b') get_archive('ddd0f15ae83993f5cb66a927a28673882e99100b')
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.header['Cache-Control']).to include('max-age=3600') expect(response.header['Cache-Control']).to include('max-age=3600')
end end
end end
...@@ -116,7 +116,7 @@ describe Projects::RepositoriesController do ...@@ -116,7 +116,7 @@ describe Projects::RepositoriesController do
request.headers['If-None-Match'] = response.headers['ETag'] request.headers['If-None-Match'] = response.headers['ETag']
get_archive get_archive
expect(response).to have_gitlab_http_status(304) expect(response).to have_gitlab_http_status(:not_modified)
end end
end end
...@@ -137,7 +137,7 @@ describe Projects::RepositoriesController do ...@@ -137,7 +137,7 @@ describe Projects::RepositoriesController do
it 'redirects to sign in page' do it 'redirects to sign in page' do
get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip' get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip'
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -146,7 +146,7 @@ describe Projects::RepositoriesController do ...@@ -146,7 +146,7 @@ describe Projects::RepositoriesController do
it 'calls the action normally' do it 'calls the action normally' do
get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master', token: user.static_object_token }, format: 'zip' get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master', token: user.static_object_token }, format: 'zip'
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -154,7 +154,7 @@ describe Projects::RepositoriesController do ...@@ -154,7 +154,7 @@ describe Projects::RepositoriesController do
it 'redirects to sign in page' do it 'redirects to sign in page' do
get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master', token: 'foobar' }, format: 'zip' get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master', token: 'foobar' }, format: 'zip'
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -165,7 +165,7 @@ describe Projects::RepositoriesController do ...@@ -165,7 +165,7 @@ describe Projects::RepositoriesController do
request.headers['X-Gitlab-Static-Object-Token'] = user.static_object_token request.headers['X-Gitlab-Static-Object-Token'] = user.static_object_token
get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip' get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip'
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -174,7 +174,7 @@ describe Projects::RepositoriesController do ...@@ -174,7 +174,7 @@ describe Projects::RepositoriesController do
request.headers['X-Gitlab-Static-Object-Token'] = 'foobar' request.headers['X-Gitlab-Static-Object-Token'] = 'foobar'
get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip' get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'master' }, format: 'zip'
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
......
...@@ -30,7 +30,7 @@ describe Projects::RunnersController do ...@@ -30,7 +30,7 @@ describe Projects::RunnersController do
runner.reload runner.reload
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(runner.description).to eq(new_desc) expect(runner.description).to eq(new_desc)
end end
end end
...@@ -39,7 +39,7 @@ describe Projects::RunnersController do ...@@ -39,7 +39,7 @@ describe Projects::RunnersController do
it 'destroys the runner' do it 'destroys the runner' do
delete :destroy, params: params delete :destroy, params: params
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(Ci::Runner.find_by(id: runner.id)).to be_nil expect(Ci::Runner.find_by(id: runner.id)).to be_nil
end end
end end
...@@ -54,7 +54,7 @@ describe Projects::RunnersController do ...@@ -54,7 +54,7 @@ describe Projects::RunnersController do
runner.reload runner.reload
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(runner.active).to eq(true) expect(runner.active).to eq(true)
end end
end end
...@@ -69,7 +69,7 @@ describe Projects::RunnersController do ...@@ -69,7 +69,7 @@ describe Projects::RunnersController do
runner.reload runner.reload
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(runner.active).to eq(false) expect(runner.active).to eq(false)
end end
end end
......
...@@ -35,7 +35,7 @@ describe Projects::SnippetsController do ...@@ -35,7 +35,7 @@ describe Projects::SnippetsController do
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(assigns(:snippets)).not_to include(project_snippet) expect(assigns(:snippets)).not_to include(project_snippet)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -48,7 +48,7 @@ describe Projects::SnippetsController do ...@@ -48,7 +48,7 @@ describe Projects::SnippetsController do
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(assigns(:snippets)).to include(project_snippet) expect(assigns(:snippets)).to include(project_snippet)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -61,7 +61,7 @@ describe Projects::SnippetsController do ...@@ -61,7 +61,7 @@ describe Projects::SnippetsController do
get :index, params: { namespace_id: project.namespace, project_id: project } get :index, params: { namespace_id: project.namespace, project_id: project }
expect(assigns(:snippets)).to include(project_snippet) expect(assigns(:snippets)).to include(project_snippet)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -318,7 +318,7 @@ describe Projects::SnippetsController do ...@@ -318,7 +318,7 @@ describe Projects::SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param } get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -331,7 +331,7 @@ describe Projects::SnippetsController do ...@@ -331,7 +331,7 @@ describe Projects::SnippetsController do
get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param } get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
expect(assigns(:snippet)).to eq(project_snippet) expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -344,7 +344,7 @@ describe Projects::SnippetsController do ...@@ -344,7 +344,7 @@ describe Projects::SnippetsController do
get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param } get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
expect(assigns(:snippet)).to eq(project_snippet) expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
end end
...@@ -354,7 +354,7 @@ describe Projects::SnippetsController do ...@@ -354,7 +354,7 @@ describe Projects::SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get action, params: { namespace_id: project.namespace, project_id: project, id: 42 } get action, params: { namespace_id: project.namespace, project_id: project, id: 42 }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -366,7 +366,7 @@ describe Projects::SnippetsController do ...@@ -366,7 +366,7 @@ describe Projects::SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
get action, params: { namespace_id: project.namespace, project_id: project, id: 42 } get action, params: { namespace_id: project.namespace, project_id: project, id: 42 }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -386,7 +386,7 @@ describe Projects::SnippetsController do ...@@ -386,7 +386,7 @@ describe Projects::SnippetsController do
let(:snippet_permission) { :private } let(:snippet_permission) { :private }
it 'responds with status 404' do it 'responds with status 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -395,7 +395,7 @@ describe Projects::SnippetsController do ...@@ -395,7 +395,7 @@ describe Projects::SnippetsController do
it 'responds with status 200' do it 'responds with status 200' do
expect(assigns(:snippet)).to eq(project_snippet) expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -407,7 +407,7 @@ describe Projects::SnippetsController do ...@@ -407,7 +407,7 @@ describe Projects::SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
expect(assigns(:snippet)).to eq(project_snippet) expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -501,7 +501,7 @@ describe Projects::SnippetsController do ...@@ -501,7 +501,7 @@ describe Projects::SnippetsController do
it 'responds with status 404' do it 'responds with status 404' do
delete :destroy, params: params delete :destroy, params: params
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -25,7 +25,7 @@ describe Projects::StagesController do ...@@ -25,7 +25,7 @@ describe Projects::StagesController do
it 'returns not authorized' do it 'returns not authorized' do
play_manual_stage! play_manual_stage!
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -110,7 +110,7 @@ describe Projects::TemplatesController do ...@@ -110,7 +110,7 @@ describe Projects::TemplatesController do
it 'returns the template names' do it 'returns the template names' do
get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json) get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
expect(json_response[0]['name']).to eq(expected_template_name) expect(json_response[0]['name']).to eq(expected_template_name)
end end
...@@ -121,7 +121,7 @@ describe Projects::TemplatesController do ...@@ -121,7 +121,7 @@ describe Projects::TemplatesController do
get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json) get(:names, params: { namespace_id: project.namespace, template_type: template_type, project_id: project }, format: :json)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
......
...@@ -22,7 +22,7 @@ describe Projects::TodosController do ...@@ -22,7 +22,7 @@ describe Projects::TodosController do
it "doesn't create todo" do it "doesn't create todo" do
expect { post_create }.not_to change { user.todos.count } expect { post_create }.not_to change { user.todos.count }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -85,7 +85,7 @@ describe Projects::TreeController do ...@@ -85,7 +85,7 @@ describe Projects::TreeController do
context "valid SHA commit ID with path" do context "valid SHA commit ID with path" do
let(:id) { '6d39438/.gitignore' } let(:id) { '6d39438/.gitignore' }
it { expect(response).to have_gitlab_http_status(302) } it { expect(response).to have_gitlab_http_status(:found) }
end end
end end
......
...@@ -49,7 +49,7 @@ describe Projects::UploadsController do ...@@ -49,7 +49,7 @@ describe Projects::UploadsController do
it "responds with status internal_server_error" do it "responds with status internal_server_error" do
post_authorize post_authorize
expect(response).to have_gitlab_http_status(500) expect(response).to have_gitlab_http_status(:internal_server_error)
expect(response.body).to eq(_('Error uploading file')) expect(response.body).to eq(_('Error uploading file'))
end end
end end
......
...@@ -24,7 +24,7 @@ describe Projects::UsagePingController do ...@@ -24,7 +24,7 @@ describe Projects::UsagePingController do
it 'returns 302' do it 'returns 302' do
subject subject
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
...@@ -32,7 +32,7 @@ describe Projects::UsagePingController do ...@@ -32,7 +32,7 @@ describe Projects::UsagePingController do
it 'returns 404' do it 'returns 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -57,7 +57,7 @@ describe Projects::UsagePingController do ...@@ -57,7 +57,7 @@ describe Projects::UsagePingController do
it 'returns 404' do it 'returns 404' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -25,7 +25,7 @@ describe Projects::WikisController do ...@@ -25,7 +25,7 @@ describe Projects::WikisController do
it 'redirects to #show and appends a `random_title` param' do it 'redirects to #show and appends a `random_title` param' do
subject subject
expect(response).to have_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(Rails.application.routes.recognize_path(response.redirect_url)).to include( expect(Rails.application.routes.recognize_path(response.redirect_url)).to include(
controller: 'projects/wikis', controller: 'projects/wikis',
action: 'show' action: 'show'
...@@ -70,7 +70,7 @@ describe Projects::WikisController do ...@@ -70,7 +70,7 @@ describe Projects::WikisController do
end end
it "returns status #{expected_status}" do it "returns status #{expected_status}" do
expect(response).to have_http_status(expected_status) expect(response).to have_gitlab_http_status(expected_status)
end end
end end
...@@ -103,7 +103,7 @@ describe Projects::WikisController do ...@@ -103,7 +103,7 @@ describe Projects::WikisController do
subject subject
expect(response).to have_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:page).title).to eq(wiki_title) expect(assigns(:page).title).to eq(wiki_title)
end end
...@@ -113,7 +113,7 @@ describe Projects::WikisController do ...@@ -113,7 +113,7 @@ describe Projects::WikisController do
subject subject
expect(response).to have_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(flash[:notice]).to eq(_('The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.')) expect(flash[:notice]).to eq(_('The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.'))
end end
end end
...@@ -204,7 +204,7 @@ describe Projects::WikisController do ...@@ -204,7 +204,7 @@ describe Projects::WikisController do
it 'shows the edit page' do it 'shows the edit page' do
subject subject
expect(response).to have_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.body).to include(s_('Wiki|Edit Page')) expect(response.body).to include(s_('Wiki|Edit Page'))
end end
end end
......
...@@ -30,6 +30,16 @@ describe SentNotificationsController do ...@@ -30,6 +30,16 @@ describe SentNotificationsController do
let(:target_project) { project } let(:target_project) { project }
describe 'GET unsubscribe' do describe 'GET unsubscribe' do
shared_examples 'returns 404' do
it 'does not set the flash message' do
expect(controller).not_to set_flash[:notice]
end
it 'returns a 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
end
context 'when the user is not logged in' do context 'when the user is not logged in' do
context 'when the force param is passed' do context 'when the force param is passed' do
before do before do
...@@ -156,6 +166,16 @@ describe SentNotificationsController do ...@@ -156,6 +166,16 @@ describe SentNotificationsController do
end end
end end
end end
context 'when the noteable associated to the notification has been deleted' do
before do
sent_notification.noteable.destroy!
get(:unsubscribe, params: { id: sent_notification.reply_key })
end
it_behaves_like 'returns 404'
end
end end
context 'when the user is logged in' do context 'when the user is logged in' do
...@@ -168,17 +188,7 @@ describe SentNotificationsController do ...@@ -168,17 +188,7 @@ describe SentNotificationsController do
get(:unsubscribe, params: { id: sent_notification.reply_key.reverse }) get(:unsubscribe, params: { id: sent_notification.reply_key.reverse })
end end
it 'does not unsubscribe the user' do it_behaves_like 'returns 404'
expect(issue.subscribed?(user, project)).to be_truthy
end
it 'does not set the flash message' do
expect(controller).not_to set_flash[:notice]
end
it 'returns a 404' do
expect(response).to have_gitlab_http_status(:not_found)
end
end end
context 'when the force param is passed' do context 'when the force param is passed' do
...@@ -254,6 +264,16 @@ describe SentNotificationsController do ...@@ -254,6 +264,16 @@ describe SentNotificationsController do
end end
end end
end end
context 'when the noteable associated to the notification has been deleted' do
before do
sent_notification.noteable.destroy!
get(:unsubscribe, params: { id: sent_notification.reply_key })
end
it_behaves_like 'returns 404'
end
end end
end end
end end
...@@ -44,6 +44,17 @@ describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do ...@@ -44,6 +44,17 @@ describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do
expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment))) expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
end end
it 'changes fragment hash if icon inside line number link is clicked' do
ending_fragment = "L7"
visit_blob
find("##{ending_fragment}").hover
find("##{ending_fragment} i").click
expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
end
it 'with initial fragment hash, changes fragment hash if line number clicked' do it 'with initial fragment hash, changes fragment hash if line number clicked' do
fragment = "L1" fragment = "L1"
ending_fragment = "L5" ending_fragment = "L5"
...@@ -83,6 +94,17 @@ describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do ...@@ -83,6 +94,17 @@ describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do
expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment))) expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment)))
end end
it 'changes fragment hash if icon inside line number link is clicked' do
ending_fragment = "L7"
visit_blob
find("##{ending_fragment}").hover
find("##{ending_fragment} i").click
expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment)))
end
it 'with initial fragment hash, changes fragment hash if line number clicked' do it 'with initial fragment hash, changes fragment hash if line number clicked' do
fragment = "L1" fragment = "L1"
ending_fragment = "L5" ending_fragment = "L5"
......
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import mountCompontent from 'helpers/vue_mount_component_helper';
import router from '~/ide/ide_router'; import router from '~/ide/ide_router';
import Item from '~/ide/components/branches/item.vue'; import Item from '~/ide/components/branches/item.vue';
import { getTimeago } from '~/lib/utils/datetime_utility'; import Icon from '~/vue_shared/components/icon.vue';
import Timeago from '~/vue_shared/components/time_ago_tooltip.vue';
import { projectData } from '../../mock_data'; import { projectData } from '../../mock_data';
const TEST_BRANCH = { const TEST_BRANCH = {
...@@ -12,45 +12,45 @@ const TEST_BRANCH = { ...@@ -12,45 +12,45 @@ const TEST_BRANCH = {
const TEST_PROJECT_ID = projectData.name_with_namespace; const TEST_PROJECT_ID = projectData.name_with_namespace;
describe('IDE branch item', () => { describe('IDE branch item', () => {
const Component = Vue.extend(Item); let wrapper;
let vm;
function createComponent(props = {}) {
beforeEach(() => { wrapper = shallowMount(Item, {
vm = mountCompontent(Component, { propsData: {
item: { ...TEST_BRANCH }, item: { ...TEST_BRANCH },
projectId: TEST_PROJECT_ID, projectId: TEST_PROJECT_ID,
isActive: false, isActive: false,
...props,
},
}); });
}); }
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
it('renders branch name and timeago', () => { describe('if not active', () => {
const timeText = getTimeago().format(TEST_BRANCH.committedDate); beforeEach(() => {
createComponent();
expect(vm.$el.textContent).toContain(TEST_BRANCH.name); });
expect(vm.$el.querySelector('time')).toHaveText(timeText); it('renders branch name and timeago', () => {
expect(vm.$el.querySelector('.ic-mobile-issue-close')).toBe(null); expect(wrapper.text()).toContain(TEST_BRANCH.name);
}); expect(wrapper.find(Timeago).props('time')).toBe(TEST_BRANCH.committedDate);
expect(wrapper.find(Icon).exists()).toBe(false);
});
it('renders link to branch', () => { it('renders link to branch', () => {
const expectedHref = router.resolve(`/project/${TEST_PROJECT_ID}/edit/${TEST_BRANCH.name}`) const expectedHref = router.resolve(`/project/${TEST_PROJECT_ID}/edit/${TEST_BRANCH.name}`)
.href; .href;
expect(vm.$el.textContent).toMatch('a'); expect(wrapper.text()).toMatch('a');
expect(vm.$el).toHaveAttr('href', expectedHref); expect(wrapper.attributes('href')).toBe(expectedHref);
});
}); });
it('renders icon if isActive', done => { it('renders icon if is not active', () => {
vm.isActive = true; createComponent({ isActive: true });
vm.$nextTick() expect(wrapper.find(Icon).exists()).toBe(true);
.then(() => {
expect(vm.$el.querySelector('.ic-mobile-issue-close')).not.toBe(null);
})
.then(done)
.catch(done.fail);
}); });
}); });
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import Icon from '~/vue_shared/components/icon.vue';
import ScrollButton from '~/ide/components/jobs/detail/scroll_button.vue'; import ScrollButton from '~/ide/components/jobs/detail/scroll_button.vue';
import mountComponent from '../../../../helpers/vue_mount_component_helper';
describe('IDE job log scroll button', () => { describe('IDE job log scroll button', () => {
const Component = Vue.extend(ScrollButton); let wrapper;
let vm;
const createComponent = props => {
beforeEach(() => { wrapper = shallowMount(ScrollButton, {
vm = mountComponent(Component, { propsData: {
direction: 'up', direction: 'up',
disabled: false, disabled: false,
...props,
},
}); });
}); };
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
describe('iconName', () => { describe.each`
['up', 'down'].forEach(direction => { direction | icon | title
it(`returns icon name for ${direction}`, () => { ${'up'} | ${'scroll_up'} | ${'Scroll to top'}
vm.direction = direction; ${'down'} | ${'scroll_down'} | ${'Scroll to bottom'}
`('for $direction direction', ({ direction, icon, title }) => {
beforeEach(() => createComponent({ direction }));
expect(vm.iconName).toBe(`scroll_${direction}`); it('returns proper icon name', () => {
}); expect(wrapper.find(Icon).props('name')).toBe(icon);
}); });
});
describe('tooltipTitle', () => { it('returns proper title', () => {
it('returns title for up', () => { expect(wrapper.attributes('data-original-title')).toBe(title);
expect(vm.tooltipTitle).toBe('Scroll to top');
});
it('returns title for down', () => {
vm.direction = 'down';
expect(vm.tooltipTitle).toBe('Scroll to bottom');
}); });
}); });
it('emits click event on click', () => { it('emits click event on click', () => {
jest.spyOn(vm, '$emit').mockImplementation(() => {}); createComponent();
vm.$el.querySelector('.btn-scroll').click();
expect(vm.$emit).toHaveBeenCalledWith('click'); wrapper.find('button').trigger('click');
expect(wrapper.emitted().click).toBeDefined();
}); });
it('disables button when disabled is true', done => { it('disables button when disabled is true', () => {
vm.disabled = true; createComponent({ disabled: true });
vm.$nextTick(() => { expect(wrapper.find('button').attributes('disabled')).toBe('disabled');
expect(vm.$el.querySelector('.btn-scroll').hasAttribute('disabled')).toBe(true);
done();
});
}); });
}); });
import Vue from 'vue'; import { shallowMount } from '@vue/test-utils';
import mountComponent from 'helpers/vue_mount_component_helper';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { GlLoadingIcon } from '@gitlab/ui';
import ClientsideNavigator from '~/ide/components/preview/navigator.vue'; import ClientsideNavigator from '~/ide/components/preview/navigator.vue';
import { listen } from 'codesandbox-api';
jest.mock('codesandbox-api', () => ({
listen: jest.fn().mockReturnValue(jest.fn()),
}));
describe('IDE clientside preview navigator', () => { describe('IDE clientside preview navigator', () => {
let vm; let wrapper;
let Component;
let manager; let manager;
let listenHandler;
beforeAll(() => { const findBackButton = () => wrapper.findAll('button').at(0);
Component = Vue.extend(ClientsideNavigator); const findForwardButton = () => wrapper.findAll('button').at(1);
}); const findRefreshButton = () => wrapper.findAll('button').at(2);
beforeEach(() => { beforeEach(() => {
listen.mockClear();
manager = { bundlerURL: TEST_HOST, iframe: { src: '' } }; manager = { bundlerURL: TEST_HOST, iframe: { src: '' } };
vm = mountComponent(Component, { manager }); wrapper = shallowMount(ClientsideNavigator, { propsData: { manager } });
[[listenHandler]] = listen.mock.calls;
}); });
afterEach(() => { afterEach(() => {
vm.$destroy(); wrapper.destroy();
}); });
it('renders readonly URL bar', () => { it('renders readonly URL bar', () => {
expect(vm.$el.querySelector('input[readonly]').value).toBe('/'); listenHandler({ type: 'urlchange', url: manager.bundlerURL });
return wrapper.vm.$nextTick(() => {
expect(wrapper.find('input[readonly]').element.value).toBe('/');
});
}); });
it('disables back button when navigationStack is empty', () => { it('renders loading icon by default', () => {
expect(vm.$el.querySelector('.ide-navigator-btn')).toHaveAttr('disabled'); expect(wrapper.find(GlLoadingIcon).exists()).toBe(true);
expect(vm.$el.querySelector('.ide-navigator-btn').classList).toContain('disabled-content');
}); });
it('disables forward button when forwardNavigationStack is empty', () => { it('removes loading icon when done event is fired', () => {
vm.forwardNavigationStack = []; listenHandler({ type: 'done' });
return wrapper.vm.$nextTick(() => {
expect(vm.$el.querySelectorAll('.ide-navigator-btn')[1]).toHaveAttr('disabled'); expect(wrapper.find(GlLoadingIcon).exists()).toBe(false);
expect(vm.$el.querySelectorAll('.ide-navigator-btn')[1].classList).toContain( });
'disabled-content',
);
}); });
it('calls back method when clicking back button', done => { it('does not count visiting same url multiple times', () => {
vm.navigationStack.push('/test'); listenHandler({ type: 'done' });
vm.navigationStack.push('/test2'); listenHandler({ type: 'done', url: `${TEST_HOST}/url1` });
jest.spyOn(vm, 'back').mockReturnValue(); listenHandler({ type: 'done', url: `${TEST_HOST}/url1` });
return wrapper.vm.$nextTick().then(() => {
vm.$nextTick(() => { expect(findBackButton().attributes('disabled')).toBe('disabled');
vm.$el.querySelector('.ide-navigator-btn').click();
expect(vm.back).toHaveBeenCalled();
done();
}); });
}); });
it('calls forward method when clicking forward button', done => { it('unsubscribes from listen on destroy', () => {
vm.forwardNavigationStack.push('/test'); const unsubscribeFn = listen();
jest.spyOn(vm, 'forward').mockReturnValue();
vm.$nextTick(() => { wrapper.destroy();
vm.$el.querySelectorAll('.ide-navigator-btn')[1].click(); expect(unsubscribeFn).toHaveBeenCalled();
expect(vm.forward).toHaveBeenCalled();
done();
});
}); });
describe('onUrlChange', () => { describe('back button', () => {
it('updates the path', () => { beforeEach(() => {
vm.onUrlChange({ url: `${TEST_HOST}/url` }); listenHandler({ type: 'done' });
listenHandler({ type: 'urlchange', url: TEST_HOST });
expect(vm.path).toBe('/url'); return wrapper.vm.$nextTick();
}); });
it('sets currentBrowsingIndex 0 if not already set', () => { it('is disabled by default', () => {
vm.onUrlChange({ url: `${TEST_HOST}/url` }); expect(findBackButton().attributes('disabled')).toBe('disabled');
expect(vm.currentBrowsingIndex).toBe(0);
}); });
it('increases currentBrowsingIndex if path doesnt match', () => { it('is enabled when there is previous entry', () => {
vm.onUrlChange({ url: `${TEST_HOST}/url` }); listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url1` });
return wrapper.vm.$nextTick().then(() => {
vm.onUrlChange({ url: `${TEST_HOST}/url2` }); findBackButton().trigger('click');
expect(findBackButton().attributes('disabled')).toBeFalsy();
expect(vm.currentBrowsingIndex).toBe(1); });
}); });
it('does not increase currentBrowsingIndex if path matches', () => { it('is disabled when there is no previous entry', () => {
vm.onUrlChange({ url: `${TEST_HOST}/url` }); listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url1` });
return wrapper.vm
vm.onUrlChange({ url: `${TEST_HOST}/url` }); .$nextTick()
.then(() => {
expect(vm.currentBrowsingIndex).toBe(0); findBackButton().trigger('click');
return wrapper.vm.$nextTick();
})
.then(() => {
expect(findBackButton().attributes('disabled')).toBe('disabled');
});
}); });
it('pushes path into navigation stack', () => { it('updates manager iframe src', () => {
vm.onUrlChange({ url: `${TEST_HOST}/url` }); listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url1` });
listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url2` });
return wrapper.vm.$nextTick().then(() => {
findBackButton().trigger('click');
expect(vm.navigationStack).toEqual(['/url']); expect(manager.iframe.src).toBe(`${TEST_HOST}/url1`);
});
}); });
}); });
describe('back', () => { describe('forward button', () => {
beforeEach(() => { beforeEach(() => {
vm.path = '/test2'; listenHandler({ type: 'done' });
vm.currentBrowsingIndex = 1; listenHandler({ type: 'urlchange', url: TEST_HOST });
vm.navigationStack.push('/test'); return wrapper.vm.$nextTick();
vm.navigationStack.push('/test2');
jest.spyOn(vm, 'visitPath').mockReturnValue();
vm.back();
}); });
it('visits the last entry in navigationStack', () => { it('is disabled by default', () => {
expect(vm.visitPath).toHaveBeenCalledWith('/test'); expect(findForwardButton().attributes('disabled')).toBe('disabled');
}); });
it('adds last entry to forwardNavigationStack', () => { it('is enabled when there is next entry', () => {
expect(vm.forwardNavigationStack).toEqual(['/test2']); listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url1` });
return wrapper.vm
.$nextTick()
.then(() => {
findBackButton().trigger('click');
return wrapper.vm.$nextTick();
})
.then(() => {
expect(findForwardButton().attributes('disabled')).toBeFalsy();
});
}); });
it('clears navigation stack if currentBrowsingIndex is 1', () => { it('is disabled when there is no next entry', () => {
expect(vm.navigationStack).toEqual([]); listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url1` });
return wrapper.vm
.$nextTick()
.then(() => {
findBackButton().trigger('click');
return wrapper.vm.$nextTick();
})
.then(() => {
findForwardButton().trigger('click');
return wrapper.vm.$nextTick();
})
.then(() => {
expect(findForwardButton().attributes('disabled')).toBe('disabled');
});
}); });
it('sets currentBrowsingIndex to null is currentBrowsingIndex is 1', () => { it('updates manager iframe src', () => {
expect(vm.currentBrowsingIndex).toBe(null); listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url1` });
}); listenHandler({ type: 'urlchange', url: `${TEST_HOST}/url2` });
}); return wrapper.vm.$nextTick().then(() => {
findBackButton().trigger('click');
describe('forward', () => {
it('calls visitPath with first entry in forwardNavigationStack', () => {
jest.spyOn(vm, 'visitPath').mockReturnValue();
vm.forwardNavigationStack.push('/test');
vm.forwardNavigationStack.push('/test2');
vm.forward(); expect(manager.iframe.src).toBe(`${TEST_HOST}/url1`);
});
expect(vm.visitPath).toHaveBeenCalledWith('/test');
}); });
}); });
describe('refresh', () => { describe('refresh button', () => {
it('calls refresh with current path', () => { const url = `${TEST_HOST}/some_url`;
jest.spyOn(vm, 'visitPath').mockReturnValue(); beforeEach(() => {
listenHandler({ type: 'done' });
vm.path = '/test'; listenHandler({ type: 'urlchange', url });
return wrapper.vm.$nextTick();
vm.refresh();
expect(vm.visitPath).toHaveBeenCalledWith('/test');
}); });
});
describe('visitPath', () => { it('calls refresh with current path', () => {
it('updates iframe src with passed in path', () => { manager.iframe.src = 'something-other';
vm.visitPath('/testpath'); findRefreshButton().trigger('click');
expect(manager.iframe.src).toBe(`${TEST_HOST}/testpath`); expect(manager.iframe.src).toBe(url);
}); });
}); });
}); });
...@@ -30,25 +30,39 @@ describe API::GroupExport do ...@@ -30,25 +30,39 @@ describe API::GroupExport do
group.add_owner(user) group.add_owner(user)
end end
context 'when export file exists' do context 'group_import_export feature flag enabled' do
before do before do
upload.export_file = fixture_file_upload('spec/fixtures/group_export.tar.gz', "`/tar.gz") stub_feature_flags(group_import_export: true)
upload.save!
end end
it 'downloads exported group archive' do context 'when export file exists' do
get api(download_path, user) before do
upload.export_file = fixture_file_upload('spec/fixtures/group_export.tar.gz', "`/tar.gz")
upload.save!
end
expect(response).to have_gitlab_http_status(200) it 'downloads exported group archive' do
end get api(download_path, user)
context 'when export_file.file does not exist' do expect(response).to have_gitlab_http_status(200)
before do end
expect_next_instance_of(ImportExportUploader) do |uploader|
expect(uploader).to receive(:file).and_return(nil) context 'when export_file.file does not exist' do
before do
expect_next_instance_of(ImportExportUploader) do |uploader|
expect(uploader).to receive(:file).and_return(nil)
end
end
it 'returns 404' do
get api(download_path, user)
expect(response).to have_gitlab_http_status(404)
end end
end end
end
context 'when export file does not exist' do
it 'returns 404' do it 'returns 404' do
get api(download_path, user) get api(download_path, user)
...@@ -57,8 +71,12 @@ describe API::GroupExport do ...@@ -57,8 +71,12 @@ describe API::GroupExport do
end end
end end
context 'when export file does not exist' do context 'group_import_export feature flag disabled' do
it 'returns 404' do before do
stub_feature_flags(group_import_export: false)
end
it 'responds with 404 Not Found' do
get api(download_path, user) get api(download_path, user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
...@@ -67,27 +85,45 @@ describe API::GroupExport do ...@@ -67,27 +85,45 @@ describe API::GroupExport do
end end
describe 'POST /groups/:group_id/export' do describe 'POST /groups/:group_id/export' do
context 'when user is a group owner' do context 'group_import_export feature flag enabled' do
before do before do
group.add_owner(user) stub_feature_flags(group_import_export: true)
end end
it 'accepts download' do context 'when user is a group owner' do
post api(path, user) before do
group.add_owner(user)
end
it 'accepts download' do
post api(path, user)
expect(response).to have_gitlab_http_status(202)
end
end
context 'when user is not a group owner' do
before do
group.add_developer(user)
end
expect(response).to have_gitlab_http_status(202) it 'forbids the request' do
post api(path, user)
expect(response).to have_gitlab_http_status(403)
end
end end
end end
context 'when user is not a group owner' do context 'group_import_export feature flag disabled' do
before do before do
group.add_developer(user) stub_feature_flags(group_import_export: false)
end end
it 'forbids the request' do it 'responds with 404 Not Found' do
post api(path, user) post api(path, user)
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(404)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment