summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.rubocop.yml17
-rw-r--r--app/finders/snippets_finder.rb4
-rw-r--r--app/views/projects/_activity.html.haml3
-rw-r--r--app/views/projects/edit.html.haml2
-rw-r--r--app/views/projects/new.html.haml2
-rw-r--r--app/views/projects/pipelines/_with_tabs.html.haml2
-rw-r--r--changelogs/unreleased/202233-migrating-fa-spinner-whithin-top-level-projects.yml5
-rw-r--r--changelogs/unreleased/208473-fix-pipeline-tab-url.yml5
-rw-r--r--changelogs/unreleased/vh-snippets-finder-tweak.yml5
-rw-r--r--danger/karma/Dangerfile50
-rw-r--r--doc/api/graphql/reference/gitlab_schema.graphql6
-rw-r--r--doc/api/graphql/reference/gitlab_schema.json6
-rw-r--r--doc/development/application_limits.md20
-rw-r--r--lib/gitlab_danger.rb1
-rw-r--r--locale/gitlab.pot3
-rw-r--r--spec/finders/snippets_finder_spec.rb11
-rw-r--r--spec/lib/gitlab_danger_spec.rb2
-rw-r--r--spec/requests/api/tags_spec.rb30
-rw-r--r--spec/requests/api/task_completion_status_spec.rb2
-rw-r--r--spec/requests/api/templates_spec.rb16
-rw-r--r--spec/requests/api/todos_spec.rb12
-rw-r--r--spec/requests/api/triggers_spec.rb54
-rw-r--r--spec/requests/api/users_spec.rb404
-rw-r--r--spec/requests/api/variables_spec.rb44
-rw-r--r--spec/requests/api/version_spec.rb6
-rw-r--r--spec/requests/api/wikis_spec.rb32
26 files changed, 407 insertions, 337 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index c8e4fc6b305..2833d31986b 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -331,26 +331,13 @@ RSpec/MissingExampleGroupArgument:
RSpec/UnspecifiedException:
Enabled: false
-# Work in progress. See https://gitlab.com/gitlab-org/gitlab/issues/196163
RSpec/HaveGitlabHttpStatus:
Enabled: true
Exclude:
- 'spec/support/matchers/have_gitlab_http_status.rb'
Include:
- - 'spec/support/**/*'
- - 'ee/spec/support/**/*'
- - 'spec/features/**/*'
- - 'ee/spec/features/**/*'
- - 'spec/controllers/**/*'
- - 'ee/spec/controllers/**/*'
- - 'spec/requests/*.rb'
- - 'ee/spec/requests/*.rb'
- - 'spec/requests/{groups,projects,repositories}/**/*'
- - 'ee/spec/requests/{groups,projects,repositories}/**/*'
- - 'spec/requests/api/*/**/*.rb'
- - 'ee/spec/requests/api/*/**/*.rb'
- - 'spec/requests/api/[a-s]*.rb'
- - 'ee/spec/requests/api/[a-s]*.rb'
+ - 'spec/**/*'
+ - 'ee/spec/**/*'
Style/MultilineWhenThen:
Enabled: false
diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb
index 5819f279eaa..4f63810423b 100644
--- a/app/finders/snippets_finder.rb
+++ b/app/finders/snippets_finder.rb
@@ -61,9 +61,11 @@ class SnippetsFinder < UnionFinder
def execute
# The snippet query can be expensive, therefore if the
# author or project params have been passed and they don't
- # exist, it's better to return
+ # exist, or if a Project has been passed and has snippets
+ # disabled, it's better to return
return Snippet.none if author.nil? && params[:author].present?
return Snippet.none if project.nil? && params[:project].present?
+ return Snippet.none if project && !project.feature_available?(:snippets, current_user)
items = init_collection
items = by_ids(items)
diff --git a/app/views/projects/_activity.html.haml b/app/views/projects/_activity.html.haml
index 12da62f4c64..07faf5a66da 100644
--- a/app/views/projects/_activity.html.haml
+++ b/app/views/projects/_activity.html.haml
@@ -6,4 +6,5 @@
= icon('rss')
.content_list.project-activity{ :"data-href" => activity_project_path(@project) }
- = spinner
+ .loading
+ .spinner.spinner-md
diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml
index 1c18487f688..3c6fb5b19a4 100644
--- a/app/views/projects/edit.html.haml
+++ b/app/views/projects/edit.html.haml
@@ -124,7 +124,7 @@
.save-project-loader.hide
.center
%h2
- %i.fa.fa-spinner.fa-spin
+ .spinner.spinner-md.align-text-bottom
= _('Saving project.')
%p= _('Please wait a moment, this page will automatically refresh when ready.')
diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml
index fabe636b05c..3ff4ab354b9 100644
--- a/app/views/projects/new.html.haml
+++ b/app/views/projects/new.html.haml
@@ -75,7 +75,7 @@
.save-project-loader.d-none
.center
%h2
- %i.fa.fa-spinner.fa-spin
+ .spinner.spinner-md.align-text-bottom
= s_('ProjectsNew|Creating project & repository.')
%p
= s_('ProjectsNew|Please wait a moment, this page will automatically refresh when ready.')
diff --git a/app/views/projects/pipelines/_with_tabs.html.haml b/app/views/projects/pipelines/_with_tabs.html.haml
index cdd75d43a78..37ca020cfb6 100644
--- a/app/views/projects/pipelines/_with_tabs.html.haml
+++ b/app/views/projects/pipelines/_with_tabs.html.haml
@@ -3,7 +3,7 @@
.tabs-holder
%ul.pipelines-tabs.nav-links.no-top.no-bottom.mobile-separator.nav.nav-tabs
%li.js-pipeline-tab-link
- = link_to @pipeline_path, data: { target: '#js-tab-pipeline', action: 'pipelines', toggle: 'tab' }, class: 'pipeline-tab' do
+ = link_to project_pipeline_path(@project, @pipeline), data: { target: '#js-tab-pipeline', action: 'pipelines', toggle: 'tab' }, class: 'pipeline-tab' do
= _('Pipeline')
%li.js-builds-tab-link
= link_to builds_project_pipeline_path(@project, @pipeline), data: { target: '#js-tab-builds', action: 'builds', toggle: 'tab' }, class: 'builds-tab' do
diff --git a/changelogs/unreleased/202233-migrating-fa-spinner-whithin-top-level-projects.yml b/changelogs/unreleased/202233-migrating-fa-spinner-whithin-top-level-projects.yml
new file mode 100644
index 00000000000..baf8183b18e
--- /dev/null
+++ b/changelogs/unreleased/202233-migrating-fa-spinner-whithin-top-level-projects.yml
@@ -0,0 +1,5 @@
+---
+title: Update loader for various project views
+merge_request: 25755
+author: Phellipe K Ribeiro
+type: other
diff --git a/changelogs/unreleased/208473-fix-pipeline-tab-url.yml b/changelogs/unreleased/208473-fix-pipeline-tab-url.yml
new file mode 100644
index 00000000000..70451260a6f
--- /dev/null
+++ b/changelogs/unreleased/208473-fix-pipeline-tab-url.yml
@@ -0,0 +1,5 @@
+---
+title: Generate proper link for Pipeline tab
+merge_request: 26193
+author:
+type: fixed
diff --git a/changelogs/unreleased/vh-snippets-finder-tweak.yml b/changelogs/unreleased/vh-snippets-finder-tweak.yml
new file mode 100644
index 00000000000..7979245a908
--- /dev/null
+++ b/changelogs/unreleased/vh-snippets-finder-tweak.yml
@@ -0,0 +1,5 @@
+---
+title: Improve SnippetsFinder performance with disabled project snippets
+merge_request: 26295
+author:
+type: performance
diff --git a/danger/karma/Dangerfile b/danger/karma/Dangerfile
new file mode 100644
index 00000000000..6d692a89e13
--- /dev/null
+++ b/danger/karma/Dangerfile
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+# rubocop:disable Style/SignalException
+
+def get_karma_files(files)
+ files.select do |file|
+ file.start_with?('ee/spec/javascripts', 'spec/javascripts') &&
+ !file.end_with?('browser_spec.js')
+ end
+end
+
+new_karma_files = get_karma_files(git.added_files.to_a)
+
+unless new_karma_files.empty?
+
+ if GitlabDanger.new(helper.gitlab_helper).ci?
+ markdown(<<~MARKDOWN)
+ ## New karma spec file
+
+ New frontend specs ([except `browser_specs`](https://gitlab.com/gitlab-org/gitlab/blob/3b6fe2f1077eedb0b8aff02a7350234f0b7dc4f9/spec/javascripts/lib/utils/browser_spec.js#L2)) should be
+ [written in jest](https://docs.gitlab.com/ee/development/testing_guide/frontend_testing.html#jest).
+
+ You have created the following tests, please migrate them over to jest:
+
+ * #{new_karma_files.map { |path| "`#{path}`" }.join("\n* ")}
+ MARKDOWN
+ end
+
+ fail "You have created a new karma spec file"
+
+end
+
+changed_karma_files = get_karma_files(helper.all_changed_files) - new_karma_files
+
+return if changed_karma_files.empty?
+
+warn 'You have edited karma spec files. Please consider migrating them to jest.'
+
+if GitlabDanger.new(helper.gitlab_helper).ci?
+ markdown(<<~MARKDOWN)
+ ## Edited karma files
+
+ You have edited the following karma spec files. Please consider migrating them to jest:
+
+ * #{changed_karma_files.map { |path| "`#{path}`" }.join("\n* ")}
+
+ In order to align with our Iteration value, migration can also be done as a follow-up.
+
+ For more information: [Jestodus epic](https://gitlab.com/groups/gitlab-org/-/epics/895)
+ MARKDOWN
+end
diff --git a/doc/api/graphql/reference/gitlab_schema.graphql b/doc/api/graphql/reference/gitlab_schema.graphql
index 808d54fd86b..d6a0cc97e25 100644
--- a/doc/api/graphql/reference/gitlab_schema.graphql
+++ b/doc/api/graphql/reference/gitlab_schema.graphql
@@ -4831,16 +4831,16 @@ enum MilestoneStateEnum {
}
"""
-The position the adjacent object should be moved.
+The position to which the adjacent object should be moved
"""
enum MoveType {
"""
- The adjacent object will be moved after the object that is being moved.
+ The adjacent object will be moved after the object that is being moved
"""
after
"""
- The adjacent object will be moved before the object that is being moved.
+ The adjacent object will be moved before the object that is being moved
"""
before
}
diff --git a/doc/api/graphql/reference/gitlab_schema.json b/doc/api/graphql/reference/gitlab_schema.json
index b7fa9b21320..4429bc6621d 100644
--- a/doc/api/graphql/reference/gitlab_schema.json
+++ b/doc/api/graphql/reference/gitlab_schema.json
@@ -24550,20 +24550,20 @@
{
"kind": "ENUM",
"name": "MoveType",
- "description": "The position the adjacent object should be moved.",
+ "description": "The position to which the adjacent object should be moved",
"fields": null,
"inputFields": null,
"interfaces": null,
"enumValues": [
{
"name": "before",
- "description": "The adjacent object will be moved before the object that is being moved.",
+ "description": "The adjacent object will be moved before the object that is being moved",
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "after",
- "description": "The adjacent object will be moved after the object that is being moved.",
+ "description": "The adjacent object will be moved after the object that is being moved",
"isDeprecated": false,
"deprecationReason": null
}
diff --git a/doc/development/application_limits.md b/doc/development/application_limits.md
index c3bfe20dd87..dd07a9cbfb7 100644
--- a/doc/development/application_limits.md
+++ b/doc/development/application_limits.md
@@ -15,10 +15,6 @@ limits](https://about.gitlab.com/handbook/product/#introducing-application-limit
## Development
-The merge request to [configure maximum number of webhooks per
-project](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/20730/diffs) is a
-good example about configuring application limits.
-
### Insert database plan limits
In the `plan_limits` table, you have to create a new column and insert the
@@ -78,12 +74,22 @@ can be used to validate that a model does not exceed the limits. It ensures
that the count of the records for the current model does not exceed the defined
limit.
-NOTE: **Note:** The name (pluralized) of the plan limit introduced in the
-database (`project_hooks`) must correspond to the name of the model we are
-validating (`ProjectHook`).
+NOTE: **Note:** You must specify the limit scope of the object being validated
+and the limit name if it's different from the pluralized model name.
```ruby
class ProjectHook
include Limitable
+
+ self.limit_name = 'project_hooks' # Optional as ProjectHook corresponds with project_hooks
+ self.limit_scope = :project
+end
+```
+
+To test the model, you can include the shared examples.
+
+```ruby
+it_behaves_like 'includes Limitable concern' do
+ subject { build(:project_hook, project: create(:project)) }
end
```
diff --git a/lib/gitlab_danger.rb b/lib/gitlab_danger.rb
index cf57b20790b..29300d02985 100644
--- a/lib/gitlab_danger.rb
+++ b/lib/gitlab_danger.rb
@@ -8,6 +8,7 @@ class GitlabDanger
duplicate_yarn_dependencies
prettier
eslint
+ karma
database
commit_messages
].freeze
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index c6faff6a46d..a6eef56feb2 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -12051,9 +12051,6 @@ msgstr ""
msgid "Maximum number of comments exceeded"
msgstr ""
-msgid "Maximum number of group hooks (%{count}) exceeded"
-msgstr ""
-
msgid "Maximum number of mirrors that can be synchronizing at the same time."
msgstr ""
diff --git a/spec/finders/snippets_finder_spec.rb b/spec/finders/snippets_finder_spec.rb
index 8f83cb77709..69e03c4c473 100644
--- a/spec/finders/snippets_finder_spec.rb
+++ b/spec/finders/snippets_finder_spec.rb
@@ -284,6 +284,17 @@ describe SnippetsFinder do
expect(described_class.new(user).execute).to contain_exactly(private_personal_snippet, internal_personal_snippet, public_personal_snippet)
end
end
+
+ context 'when project snippets are disabled' do
+ it 'returns quickly' do
+ disabled_snippets_project = create(:project, :snippets_disabled)
+ finder = described_class.new(user, project: disabled_snippets_project.id)
+
+ expect(finder).not_to receive(:init_collection)
+ expect(Snippet).to receive(:none).and_call_original
+ expect(finder.execute).to be_empty
+ end
+ end
end
it_behaves_like 'snippet visibility'
diff --git a/spec/lib/gitlab_danger_spec.rb b/spec/lib/gitlab_danger_spec.rb
index 18321541221..d3d7357a012 100644
--- a/spec/lib/gitlab_danger_spec.rb
+++ b/spec/lib/gitlab_danger_spec.rb
@@ -9,7 +9,7 @@ describe GitlabDanger do
describe '.local_warning_message' do
it 'returns an informational message with rules that can run' do
- expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, database, commit_messages')
+ expect(described_class.local_warning_message).to eq('==> Only the following Danger rules can be run locally: changes_size, documentation, frozen_string, duplicate_yarn_dependencies, prettier, eslint, karma, database, commit_messages')
end
end
diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb
index 09e63b86cfc..694802ce1b8 100644
--- a/spec/requests/api/tags_spec.rb
+++ b/spec/requests/api/tags_spec.rb
@@ -61,7 +61,7 @@ describe API::Tags do
it 'only returns searched tags' do
get api("#{route}", user), params: { search: 'v1.1.0' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
@@ -73,7 +73,7 @@ describe API::Tags do
it 'returns the repository tags' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/tags')
expect(response).to include_pagination_headers
expect(json_response.map { |r| r['name'] }).to include(tag_name)
@@ -133,7 +133,7 @@ describe API::Tags do
it 'returns an array of project tags with release info' do
get api(route, user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/tags')
expect(response).to include_pagination_headers
@@ -151,7 +151,7 @@ describe API::Tags do
it 'returns the repository branch' do
get api(route, current_user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq(tag_name)
end
@@ -214,7 +214,7 @@ describe API::Tags do
it 'creates a new tag' do
post api(route, current_user), params: { tag_name: tag_name, ref: 'master' }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq(tag_name)
end
@@ -269,26 +269,26 @@ describe API::Tags do
it 'returns 400 if tag name is invalid' do
post api(route, current_user), params: { tag_name: 'new design', ref: 'master' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Tag name invalid')
end
it 'returns 400 if tag already exists' do
post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/tag')
post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Tag new_design1 already exists')
end
it 'returns 400 if ref name is invalid' do
post api(route, current_user), params: { tag_name: 'new_design3', ref: 'foo' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Target foo is invalid')
end
@@ -296,7 +296,7 @@ describe API::Tags do
it 'creates a new tag' do
post api(route, current_user), params: { tag_name: tag_name, ref: 'master', release_description: 'Wow' }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq(tag_name)
expect(json_response['release']['description']).to eq('Wow')
@@ -315,7 +315,7 @@ describe API::Tags do
post api(route, current_user), params: { tag_name: 'v7.1.0', ref: 'master', message: 'Release 7.1.0' }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq('v7.1.0')
expect(json_response['message']).to eq('Release 7.1.0')
@@ -337,7 +337,7 @@ describe API::Tags do
it 'deletes a tag' do
delete api(route, current_user)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end
it_behaves_like '412 response' do
@@ -383,7 +383,7 @@ describe API::Tags do
it 'creates description for existing git tag' do
post api(route, user), params: { description: description }
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/release/tag_release')
expect(json_response['tag_name']).to eq(tag_name)
expect(json_response['description']).to eq(description)
@@ -424,7 +424,7 @@ describe API::Tags do
it 'returns 409 if there is already a release' do
post api(route, user), params: { description: description }
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('Release already exists')
end
end
@@ -449,7 +449,7 @@ describe API::Tags do
it 'updates the release description' do
put api(route, current_user), params: { description: new_description }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['tag_name']).to eq(tag_name)
expect(json_response['description']).to eq(new_description)
end
diff --git a/spec/requests/api/task_completion_status_spec.rb b/spec/requests/api/task_completion_status_spec.rb
index a2891e1d983..4dd1e27bd4b 100644
--- a/spec/requests/api/task_completion_status_spec.rb
+++ b/spec/requests/api/task_completion_status_spec.rb
@@ -57,7 +57,7 @@ describe 'task completion status response' do
get api("#{path}?iids[]=#{taskable.iid}", user)
end
- it { expect(response).to have_gitlab_http_status(200) }
+ it { expect(response).to have_gitlab_http_status(:ok) }
it 'returns the expected results' do
expect(json_response).to be_an Array
diff --git a/spec/requests/api/templates_spec.rb b/spec/requests/api/templates_spec.rb
index b6ba417d892..fae338b4ca3 100644
--- a/spec/requests/api/templates_spec.rb
+++ b/spec/requests/api/templates_spec.rb
@@ -25,7 +25,7 @@ describe API::Templates do
it 'returns a list of available gitignore templates' do
get api('/templates/gitignores')
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to be > 15
@@ -36,7 +36,7 @@ describe API::Templates do
it 'returns a list of available gitlab_ci_ymls' do
get api('/templates/gitlab_ci_ymls')
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['name']).not_to be_nil
@@ -47,7 +47,7 @@ describe API::Templates do
it 'adds a disclaimer on the top' do
get api('/templates/gitlab_ci_ymls/Ruby')
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['content']).to start_with("# This file is a template,")
end
end
@@ -58,7 +58,7 @@ describe API::Templates do
end
it 'returns a license template' do
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['key']).to eq('mit')
expect(json_response['name']).to eq('MIT License')
@@ -78,7 +78,7 @@ describe API::Templates do
it 'returns a list of available license templates' do
get api('/templates/licenses')
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(12)
@@ -90,7 +90,7 @@ describe API::Templates do
it 'returns a list of available popular license templates' do
get api('/templates/licenses?popular=1')
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
@@ -173,7 +173,7 @@ describe API::Templates do
let(:license_type) { 'muth-over9000' }
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
@@ -185,7 +185,7 @@ describe API::Templates do
it 'replaces the copyright owner placeholder with the name of the current user' do
get api('/templates/licenses/mit', user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['content']).to include("Copyright (c) #{Time.now.year} #{user.name}")
end
end
diff --git a/spec/requests/api/todos_spec.rb b/spec/requests/api/todos_spec.rb
index 4121a0f3f3a..7a7712c2f5d 100644
--- a/spec/requests/api/todos_spec.rb
+++ b/spec/requests/api/todos_spec.rb
@@ -166,7 +166,7 @@ describe API::Todos do
it 'returns authentication error' do
post api("/todos/#{pending_1.id}/mark_as_done")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -174,7 +174,7 @@ describe API::Todos do
it 'marks a todo as done' do
post api("/todos/#{pending_1.id}/mark_as_done", john_doe)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['id']).to eq(pending_1.id)
expect(json_response['state']).to eq('done')
expect(pending_1.reload).to be_done
@@ -199,7 +199,7 @@ describe API::Todos do
it 'returns authentication error' do
post api('/todos/mark_as_done')
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -207,7 +207,7 @@ describe API::Todos do
it 'marks all todos as done' do
post api('/todos/mark_as_done', john_doe)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
expect(pending_1.reload).to be_done
expect(pending_2.reload).to be_done
expect(pending_3.reload).to be_done
@@ -258,9 +258,9 @@ describe API::Todos do
post api("/projects/#{project_1.id}/#{issuable_type}/#{issuable.iid}/todo", guest)
if issuable_type == 'merge_requests'
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
else
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb
index 35e41f5ae52..0309618e243 100644
--- a/spec/requests/api/triggers_spec.rb
+++ b/spec/requests/api/triggers_spec.rb
@@ -31,13 +31,13 @@ describe API::Triggers do
it 'returns bad request if token is missing' do
post api("/projects/#{project.id}/trigger/pipeline"), params: { ref: 'master' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns not found if project is not found' do
post api('/projects/0/trigger/pipeline'), params: options.merge(ref: 'master')
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -47,7 +47,7 @@ describe API::Triggers do
it 'creates pipeline' do
post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'master')
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response).to include('id' => pipeline.id)
pipeline.builds.reload
expect(pipeline.builds.pending.size).to eq(2)
@@ -57,7 +57,7 @@ describe API::Triggers do
it 'returns bad request with no pipeline created if there\'s no commit for that ref' do
post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'other-branch')
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('base' => ["Reference not found"])
end
@@ -69,21 +69,21 @@ describe API::Triggers do
it 'validates variables to be a hash' do
post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: 'value', ref: 'master')
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('variables is invalid')
end
it 'validates variables needs to be a map of key-valued strings' do
post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: { key: %w(1 2) }, ref: 'master')
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('variables needs to be a map of key-valued strings')
end
it 'creates trigger request with variables' do
post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: variables, ref: 'master')
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables)
end
end
@@ -93,7 +93,7 @@ describe API::Triggers do
it 'does not leak the presence of project when token is for different project' do
post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'creates builds from the ref given in the URL, not in the body' do
@@ -101,7 +101,7 @@ describe API::Triggers do
post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' }
end.to change(project.builds, :count).by(5)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end
context 'when ref contains a dot' do
@@ -112,7 +112,7 @@ describe API::Triggers do
post api("/projects/#{project.id}/ref/v.1-branch/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' }
end.to change(project.builds, :count).by(4)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end
end
end
@@ -123,7 +123,7 @@ describe API::Triggers do
it 'returns a list of triggers with tokens exposed correctly' do
get api("/projects/#{project.id}/triggers", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_a(Array)
@@ -137,7 +137,7 @@ describe API::Triggers do
it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -145,7 +145,7 @@ describe API::Triggers do
it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -155,14 +155,14 @@ describe API::Triggers do
it 'returns trigger details' do
get api("/projects/#{project.id}/triggers/#{trigger.id}", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a(Hash)
end
it 'responds with 404 Not Found if requesting non-existing trigger' do
get api("/projects/#{project.id}/triggers/-5", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -170,7 +170,7 @@ describe API::Triggers do
it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers/#{trigger.id}", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -178,7 +178,7 @@ describe API::Triggers do
it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers/#{trigger.id}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -192,7 +192,7 @@ describe API::Triggers do
params: { description: 'trigger' }
end.to change {project.triggers.count}.by(1)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response).to include('description' => 'trigger')
end
end
@@ -211,7 +211,7 @@ describe API::Triggers do
post api("/projects/#{project.id}/triggers", user2),
params: { description: 'trigger' }
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -220,7 +220,7 @@ describe API::Triggers do
post api("/projects/#{project.id}/triggers"),
params: { description: 'trigger' }
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -233,7 +233,7 @@ describe API::Triggers do
put api("/projects/#{project.id}/triggers/#{trigger.id}", user),
params: { description: new_description }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include('description' => new_description)
expect(trigger.reload.description).to eq(new_description)
end
@@ -243,7 +243,7 @@ describe API::Triggers do
it 'does not update trigger' do
put api("/projects/#{project.id}/triggers/#{trigger.id}", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -251,7 +251,7 @@ describe API::Triggers do
it 'does not update trigger' do
put api("/projects/#{project.id}/triggers/#{trigger.id}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -262,14 +262,14 @@ describe API::Triggers do
expect do
delete api("/projects/#{project.id}/triggers/#{trigger.id}", user)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end.to change {project.triggers.count}.by(-1)
end
it 'responds with 404 Not Found if requesting non-existing trigger' do
delete api("/projects/#{project.id}/triggers/-5", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it_behaves_like '412 response' do
@@ -281,7 +281,7 @@ describe API::Triggers do
it 'does not delete trigger' do
delete api("/projects/#{project.id}/triggers/#{trigger.id}", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -289,7 +289,7 @@ describe API::Triggers do
it 'does not delete trigger' do
delete api("/projects/#{project.id}/triggers/#{trigger.id}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index 73bdd3b5d96..8b9d0391b79 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -41,7 +41,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns authorization error when the `username` parameter is not passed" do
get api("/users")
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it "returns the user when a valid `username` parameter is passed" do
@@ -65,7 +65,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns an empty response when an invalid `username` parameter is passed" do
get api("/users"), params: { username: 'invalid' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response.size).to eq(0)
end
@@ -93,13 +93,13 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns authorization error when the `username` parameter refers to an inaccessible user" do
get api("/users"), params: { username: user.username }
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it "returns authorization error when the `username` parameter is not passed" do
get api("/users")
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
@@ -169,7 +169,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns a 403 when non-admin user searches by external UID" do
get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}&provider=#{omniauth_user.identities.first.provider}", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'does not reveal the `is_admin` flag of the user' do
@@ -218,13 +218,13 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns 400 error if provider with no extern_uid" do
get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}", admin)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it "returns 400 error if provider with no extern_uid" do
get api("/users?provider=#{omniauth_user.identities.first.provider}", admin)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it "returns a user created before a specific date" do
@@ -283,7 +283,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 400 when provided incorrect sort params' do
get api('/users', admin), params: { order_by: 'magic', sort: 'asc' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -293,7 +293,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/users", user), params: { skip_ldap: "true" }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response.first["username"]).to eq user.username
end
@@ -403,7 +403,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/users/#{user.id}")
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it "returns the `created_at` field for public users" do
@@ -424,14 +424,14 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns a 404 error if user id not found" do
get api("/users/0", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it "returns a 404 for invalid ID" do
get api("/users/1ASDF", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -468,7 +468,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "creates user with correct attributes" do
post api('/users', admin), params: attributes_for(:user, admin: true, can_create_group: true)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
expect(new_user.admin).to eq(true)
@@ -481,12 +481,12 @@ describe API::Users, :do_not_mock_admin_mode do
post api('/users', admin), params: attributes
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end
it "creates non-admin user" do
post api('/users', admin), params: attributes_for(:user, admin: false, can_create_group: false)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
expect(new_user.admin).to eq(false)
@@ -495,7 +495,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "creates non-admin users by default" do
post api('/users', admin), params: attributes_for(:user)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
expect(new_user.admin).to eq(false)
@@ -504,12 +504,12 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns 201 Created on success" do
post api("/users", admin), params: attributes_for(:user, projects_limit: 3)
expect(response).to match_response_schema('public_api/v4/user/admin')
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end
it 'creates non-external users by default' do
post api("/users", admin), params: attributes_for(:user)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
@@ -518,7 +518,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'allows an external user to be created' do
post api("/users", admin), params: attributes_for(:user, external: true)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
@@ -528,7 +528,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "creates user with reset password" do
post api('/users', admin), params: attributes_for(:user, reset_password: true).except(:password)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
@@ -540,7 +540,7 @@ describe API::Users, :do_not_mock_admin_mode do
params = attributes_for(:user, force_random_password: true, reset_password: true)
post api('/users', admin), params: params
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
@@ -552,7 +552,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "creates user with private profile" do
post api('/users', admin), params: attributes_for(:user, private_profile: true)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
user_id = json_response['id']
new_user = User.find(user_id)
@@ -568,27 +568,27 @@ describe API::Users, :do_not_mock_admin_mode do
password: 'password',
name: 'test'
}
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 error if name not given' do
post api('/users', admin), params: attributes_for(:user).except(:name)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 error if password not given' do
post api('/users', admin), params: attributes_for(:user).except(:password)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 error if email not given' do
post api('/users', admin), params: attributes_for(:user).except(:email)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 error if username not given' do
post api('/users', admin), params: attributes_for(:user).except(:username)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it "doesn't create user with invalid optional attributes" do
@@ -597,7 +597,7 @@ describe API::Users, :do_not_mock_admin_mode do
post api('/users', admin), params: attributes
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 error if user does not validate' do
@@ -610,7 +610,7 @@ describe API::Users, :do_not_mock_admin_mode do
bio: 'g' * 256,
projects_limit: -1
}
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['password'])
.to eq(['is too short (minimum is 8 characters)'])
expect(json_response['message']['bio'])
@@ -623,7 +623,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "is not available for non admin users" do
post api("/users", user), params: attributes_for(:user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
context 'with existing user' do
@@ -647,7 +647,7 @@ describe API::Users, :do_not_mock_admin_mode do
username: 'foo'
}
end.to change { User.count }.by(0)
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('Email has already been taken')
end
@@ -661,7 +661,7 @@ describe API::Users, :do_not_mock_admin_mode do
username: 'test'
}
end.to change { User.count }.by(0)
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('Username has already been taken')
end
@@ -675,14 +675,14 @@ describe API::Users, :do_not_mock_admin_mode do
username: 'TEST'
}
end.to change { User.count }.by(0)
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(json_response['message']).to eq('Username has already been taken')
end
it 'creates user with new identity' do
post api("/users", admin), params: attributes_for(:user, provider: 'github', extern_uid: '67890')
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['identities'].first['extern_uid']).to eq('67890')
expect(json_response['identities'].first['provider']).to eq('github')
end
@@ -704,13 +704,13 @@ describe API::Users, :do_not_mock_admin_mode do
put api("/users/#{user.id}", admin), params: { bio: 'new test bio' }
expect(response).to match_response_schema('public_api/v4/user/admin')
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
it "updates user with new bio" do
put api("/users/#{user.id}", admin), params: { bio: 'new test bio' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['bio']).to eq('new test bio')
expect(user.reload.bio).to eq('new test bio')
end
@@ -718,14 +718,14 @@ describe API::Users, :do_not_mock_admin_mode do
it "updates user with new password and forces reset on next login" do
put api("/users/#{user.id}", admin), params: { password: '12345678' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.password_expires_at).to be <= Time.now
end
it "updates user with organization" do
put api("/users/#{user.id}", admin), params: { organization: 'GitLab' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['organization']).to eq('GitLab')
expect(user.reload.organization).to eq('GitLab')
end
@@ -736,7 +736,7 @@ describe API::Users, :do_not_mock_admin_mode do
user.reload
expect(user.avatar).to be_present
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['avatar_url']).to include(user.avatar_path)
end
@@ -747,7 +747,7 @@ describe API::Users, :do_not_mock_admin_mode do
user.reload
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user).to be_confirmed
expect(user.email).to eq(old_email)
expect(user.notification_email).to eq(old_notification_email)
@@ -759,7 +759,7 @@ describe API::Users, :do_not_mock_admin_mode do
user.reload
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user).to be_confirmed
expect(user.email).to eq('new@email.com')
end
@@ -767,7 +767,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'updates user with their own username' do
put api("/users/#{user.id}", admin), params: { username: user.username }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['username']).to eq(user.username)
expect(user.reload.username).to eq(user.username)
end
@@ -775,14 +775,14 @@ describe API::Users, :do_not_mock_admin_mode do
it "updates user's existing identity" do
put api("/users/#{omniauth_user.id}", admin), params: { provider: 'ldapmain', extern_uid: '654321' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(omniauth_user.reload.identities.first.extern_uid).to eq('654321')
end
it 'updates user with new identity' do
put api("/users/#{user.id}", admin), params: { provider: 'github', extern_uid: 'john' }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.identities.first.extern_uid).to eq('john')
expect(user.reload.identities.first.provider).to eq('github')
end
@@ -790,7 +790,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "updates admin status" do
put api("/users/#{user.id}", admin), params: { admin: true }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.admin).to eq(true)
end
@@ -811,7 +811,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "updates private profile" do
put api("/users/#{user.id}", admin), params: { private_profile: true }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.private_profile).to eq(true)
end
@@ -820,7 +820,7 @@ describe API::Users, :do_not_mock_admin_mode do
put api("/users/#{user.id}", admin), params: { private_profile: nil }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.private_profile).to eq(false)
end
@@ -829,14 +829,14 @@ describe API::Users, :do_not_mock_admin_mode do
put api("/users/#{user.id}", admin), params: {}
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.private_profile).to eq(true)
end
it "does not update admin status" do
put api("/users/#{admin_user.id}", admin), params: { can_create_group: false }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(admin_user.reload.admin).to eq(true)
expect(admin_user.can_create_group).to eq(false)
end
@@ -844,35 +844,35 @@ describe API::Users, :do_not_mock_admin_mode do
it "does not allow invalid update" do
put api("/users/#{user.id}", admin), params: { email: 'invalid email' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(user.reload.email).not_to eq('invalid email')
end
it "updates theme id" do
put api("/users/#{user.id}", admin), params: { theme_id: 5 }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.theme_id).to eq(5)
end
it "does not update invalid theme id" do
put api("/users/#{user.id}", admin), params: { theme_id: 50 }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(user.reload.theme_id).not_to eq(50)
end
it "updates color scheme id" do
put api("/users/#{user.id}", admin), params: { color_scheme_id: 5 }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(user.reload.color_scheme_id).to eq(5)
end
it "does not update invalid color scheme id" do
put api("/users/#{user.id}", admin), params: { color_scheme_id: 50 }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(user.reload.color_scheme_id).not_to eq(50)
end
@@ -882,21 +882,21 @@ describe API::Users, :do_not_mock_admin_mode do
put api("/users/#{user.id}", user), params: attributes_for(:user)
end.not_to change { user.reload.attributes }
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
it "returns 404 for non-existing user" do
put api("/users/0", admin), params: { bio: 'update should fail' }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it "returns a 404 if invalid ID" do
put api("/users/ASDF", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns 400 error if user does not validate' do
@@ -909,7 +909,7 @@ describe API::Users, :do_not_mock_admin_mode do
bio: 'g' * 256,
projects_limit: -1
}
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['password'])
.to eq(['is too short (minimum is 8 characters)'])
expect(json_response['message']['bio'])
@@ -923,13 +923,13 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 400 if provider is missing for identity update' do
put api("/users/#{omniauth_user.id}", admin), params: { extern_uid: '654321' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 if external UID is missing for identity update' do
put api("/users/#{omniauth_user.id}", admin), params: { provider: 'ldap' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
context "with existing user" do
@@ -942,7 +942,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 409 conflict error if email address exists' do
put api("/users/#{@user.id}", admin), params: { email: 'test@example.com' }
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(@user.reload.email).to eq(@user.email)
end
@@ -950,7 +950,7 @@ describe API::Users, :do_not_mock_admin_mode do
@user_id = User.all.last.id
put api("/users/#{@user.id}", admin), params: { username: 'test' }
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(@user.reload.username).to eq(@user.username)
end
@@ -958,7 +958,7 @@ describe API::Users, :do_not_mock_admin_mode do
@user_id = User.all.last.id
put api("/users/#{@user.id}", admin), params: { username: 'TEST' }
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
expect(@user.reload.username).to eq(@user.username)
end
end
@@ -1011,14 +1011,14 @@ describe API::Users, :do_not_mock_admin_mode do
it "does not create invalid ssh key" do
post api("/users/#{user.id}/keys", admin), params: { title: "invalid key" }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('key is missing')
end
it 'does not create key without title' do
post api("/users/#{user.id}/keys", admin), params: { key: 'some key' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('title is missing')
end
@@ -1031,7 +1031,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns 400 for invalid ID" do
post api("/users/0/keys", admin)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -1041,7 +1041,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/users/#{user_id}/keys")
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
@@ -1051,7 +1051,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/users/#{user.id}/keys")
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(key.title)
@@ -1062,7 +1062,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 404 for non-existing user' do
get api("/users/#{not_existing_user_id}/keys")
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
@@ -1072,7 +1072,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/users/#{user.username}/keys")
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(key.title)
@@ -1087,7 +1087,7 @@ describe API::Users, :do_not_mock_admin_mode do
context 'when unauthenticated' do
it 'returns authentication error' do
delete api("/users/#{user.id}/keys/42")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -1099,7 +1099,7 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
delete api("/users/#{user.id}/keys/#{key.id}", admin)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end.to change { user.keys.count }.by(-1)
end
@@ -1111,13 +1111,13 @@ describe API::Users, :do_not_mock_admin_mode do
user.keys << key
user.save
delete api("/users/0/keys/#{key.id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns 404 error if key not foud' do
delete api("/users/#{user.id}/keys/42", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Key Not Found')
end
end
@@ -1131,7 +1131,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'does not create invalid GPG key' do
post api("/users/#{user.id}/gpg_keys", admin)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('key is missing')
end
@@ -1140,14 +1140,14 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
post api("/users/#{user.id}/gpg_keys", admin), params: key_attrs
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end.to change { user.gpg_keys.count }.by(1)
end
it 'returns 400 for invalid ID' do
post api('/users/0/gpg_keys', admin)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -1160,7 +1160,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns authentication error' do
get api("/users/#{user.id}/gpg_keys")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -1168,14 +1168,14 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 404 for non-existing user' do
get api('/users/0/gpg_keys', admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns 404 error if key not foud' do
delete api("/users/#{user.id}/gpg_keys/42", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 GPG Key Not Found')
end
@@ -1185,7 +1185,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/users/#{user.id}/gpg_keys", admin)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['key']).to eq(gpg_key.key)
@@ -1202,7 +1202,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns authentication error' do
delete api("/users/#{user.id}/keys/42")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -1214,7 +1214,7 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
delete api("/users/#{user.id}/gpg_keys/#{gpg_key.id}", admin)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end.to change { user.gpg_keys.count }.by(-1)
end
@@ -1224,14 +1224,14 @@ describe API::Users, :do_not_mock_admin_mode do
delete api("/users/0/gpg_keys/#{gpg_key.id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns 404 error if key not foud' do
delete api("/users/#{user.id}/gpg_keys/42", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 GPG Key Not Found')
end
end
@@ -1246,7 +1246,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns authentication error' do
post api("/users/#{user.id}/gpg_keys/42/revoke")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -1268,14 +1268,14 @@ describe API::Users, :do_not_mock_admin_mode do
post api("/users/0/gpg_keys/#{gpg_key.id}/revoke", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns 404 error if key not foud' do
post api("/users/#{user.id}/gpg_keys/42/revoke", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 GPG Key Not Found')
end
end
@@ -1289,7 +1289,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "does not create invalid email" do
post api("/users/#{user.id}/emails", admin), params: {}
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('email is missing')
end
@@ -1306,7 +1306,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns a 400 for invalid ID" do
post api("/users/0/emails", admin)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it "creates verified email" do
@@ -1315,7 +1315,7 @@ describe API::Users, :do_not_mock_admin_mode do
post api("/users/#{user.id}/emails", admin), params: email_attrs
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
email = Email.find_by(user_id: user.id, email: email_attrs[:email])
expect(email).to be_confirmed
@@ -1330,14 +1330,14 @@ describe API::Users, :do_not_mock_admin_mode do
context 'when unauthenticated' do
it 'returns authentication error' do
get api("/users/#{user.id}/emails")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
context 'when authenticated' do
it 'returns 404 for non-existing user' do
get api('/users/0/emails', admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
@@ -1347,7 +1347,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/users/#{user.id}/emails", admin)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['email']).to eq(email.email)
@@ -1356,7 +1356,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns a 404 for invalid ID" do
get api("/users/ASDF/emails", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@@ -1369,7 +1369,7 @@ describe API::Users, :do_not_mock_admin_mode do
context 'when unauthenticated' do
it 'returns authentication error' do
delete api("/users/#{user.id}/emails/42")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -1381,7 +1381,7 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
delete api("/users/#{user.id}/emails/#{email.id}", admin)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end.to change { user.emails.count }.by(-1)
end
@@ -1393,20 +1393,20 @@ describe API::Users, :do_not_mock_admin_mode do
user.emails << email
user.save
delete api("/users/0/emails/#{email.id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns 404 error if email not foud' do
delete api("/users/#{user.id}/emails/42", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Email Not Found')
end
it "returns a 404 for invalid ID" do
delete api("/users/ASDF/emails/bar", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
end
@@ -1422,7 +1422,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "deletes user", :sidekiq_might_not_need_inline do
perform_enqueued_jobs { delete api("/users/#{user.id}", admin) }
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
expect { User.find(user.id) }.to raise_error ActiveRecord::RecordNotFound
expect { Namespace.find(namespace.id) }.to raise_error ActiveRecord::RecordNotFound
end
@@ -1433,14 +1433,14 @@ describe API::Users, :do_not_mock_admin_mode do
context "hard delete disabled" do
it "does not delete user" do
perform_enqueued_jobs { delete api("/users/#{user.id}", admin)}
- expect(response).to have_gitlab_http_status(409)
+ expect(response).to have_gitlab_http_status(:conflict)
end
end
context "hard delete enabled" do
it "delete user and group", :sidekiq_might_not_need_inline do
perform_enqueued_jobs { delete api("/users/#{user.id}?hard_delete=true", admin)}
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
expect(Group.exists?(group.id)).to be_falsy
end
end
@@ -1452,31 +1452,31 @@ describe API::Users, :do_not_mock_admin_mode do
it "does not delete for unauthenticated user" do
perform_enqueued_jobs { delete api("/users/#{user.id}") }
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
it "is not available for non admin users" do
perform_enqueued_jobs { delete api("/users/#{user.id}", user) }
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it "returns 404 for non-existing user" do
perform_enqueued_jobs { delete api("/users/0", admin) }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it "returns a 404 for invalid ID" do
perform_enqueued_jobs { delete api("/users/ASDF", admin) }
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
context "hard delete disabled" do
it "moves contributions to the ghost user", :sidekiq_might_not_need_inline do
perform_enqueued_jobs { delete api("/users/#{user.id}", admin) }
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
expect(issue.reload).to be_persisted
expect(issue.author.ghost?).to be_truthy
end
@@ -1486,7 +1486,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "removes contributions", :sidekiq_might_not_need_inline do
perform_enqueued_jobs { delete api("/users/#{user.id}?hard_delete=true", admin) }
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
expect(Issue.exists?(issue.id)).to be_falsy
end
end
@@ -1501,14 +1501,14 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 403 without private token when sudo is defined' do
get api("/user?private_token=#{personal_access_token}&sudo=123", version: version)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
it 'returns current user without private token when sudo not defined' do
get api("/user", user, version: version)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/user/public')
expect(json_response['id']).to eq(user.id)
end
@@ -1528,13 +1528,13 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 403 without private token when sudo defined' do
get api("/user?private_token=#{admin_personal_access_token}&sudo=#{user.id}", version: version)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
it 'returns initial current user without private token but with is_admin when sudo not defined' do
get api("/user?private_token=#{admin_personal_access_token}", version: version)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/user/admin')
expect(json_response['id']).to eq(admin.id)
end
@@ -1545,7 +1545,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns 401 error if user is unauthenticated" do
get api("/user", version: version)
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -1558,7 +1558,7 @@ describe API::Users, :do_not_mock_admin_mode do
context "when unauthenticated" do
it "returns authentication error" do
get api("/user/keys")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -1569,7 +1569,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/user/keys", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first["title"]).to eq(key.title)
@@ -1589,14 +1589,14 @@ describe API::Users, :do_not_mock_admin_mode do
user.keys << key
user.save
get api("/user/keys/#{key.id}", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response["title"]).to eq(key.title)
end
it "returns 404 Not Found within invalid ID" do
get api("/user/keys/42", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Key Not Found')
end
@@ -1605,14 +1605,14 @@ describe API::Users, :do_not_mock_admin_mode do
user.save
admin
get api("/user/keys/#{key.id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Key Not Found')
end
it "returns 404 for invalid ID" do
get api("/users/keys/ASDF", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
context "scopes" do
@@ -1629,31 +1629,31 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
post api("/user/keys", user), params: key_attrs
end.to change { user.keys.count }.by(1)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end
it "returns a 401 error if unauthorized" do
post api("/user/keys"), params: { title: 'some title', key: 'some key' }
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
it "does not create ssh key without key" do
post api("/user/keys", user), params: { title: 'title' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('key is missing')
end
it 'does not create ssh key without title' do
post api('/user/keys', user), params: { key: 'some key' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('title is missing')
end
it "does not create ssh key without title" do
post api("/user/keys", user), params: { key: "somekey" }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
@@ -1665,7 +1665,7 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
delete api("/user/keys/#{key.id}", user)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end.to change { user.keys.count}.by(-1)
end
@@ -1676,7 +1676,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns 404 if key ID not found" do
delete api("/user/keys/42", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Key Not Found')
end
@@ -1684,13 +1684,13 @@ describe API::Users, :do_not_mock_admin_mode do
user.keys << key
user.save
delete api("/user/keys/#{key.id}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
it "returns a 404 for invalid ID" do
delete api("/users/keys/ASDF", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -1699,7 +1699,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns authentication error' do
get api('/user/gpg_keys')
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -1710,7 +1710,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api('/user/gpg_keys', user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['key']).to eq(gpg_key.key)
@@ -1732,14 +1732,14 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/user/gpg_keys/#{gpg_key.id}", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['key']).to eq(gpg_key.key)
end
it 'returns 404 Not Found within invalid ID' do
get api('/user/gpg_keys/42', user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 GPG Key Not Found')
end
@@ -1749,14 +1749,14 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/user/gpg_keys/#{gpg_key.id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 GPG Key Not Found')
end
it 'returns 404 for invalid ID' do
get api('/users/gpg_keys/ASDF', admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
context 'scopes' do
@@ -1773,20 +1773,20 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
post api('/user/gpg_keys', user), params: key_attrs
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end.to change { user.gpg_keys.count }.by(1)
end
it 'returns a 401 error if unauthorized' do
post api('/user/gpg_keys'), params: { key: 'some key' }
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'does not create GPG key without key' do
post api('/user/gpg_keys', user)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('key is missing')
end
end
@@ -1806,7 +1806,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 404 if key ID not found' do
post api('/user/gpg_keys/42/revoke', user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 GPG Key Not Found')
end
@@ -1816,13 +1816,13 @@ describe API::Users, :do_not_mock_admin_mode do
post api("/user/gpg_keys/#{gpg_key.id}/revoke")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns a 404 for invalid ID' do
post api('/users/gpg_keys/ASDF/revoke', admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -1834,14 +1834,14 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
delete api("/user/gpg_keys/#{gpg_key.id}", user)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end.to change { user.gpg_keys.count}.by(-1)
end
it 'returns 404 if key ID not found' do
delete api('/user/gpg_keys/42', user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 GPG Key Not Found')
end
@@ -1851,13 +1851,13 @@ describe API::Users, :do_not_mock_admin_mode do
delete api("/user/gpg_keys/#{gpg_key.id}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns a 404 for invalid ID' do
delete api('/users/gpg_keys/ASDF', admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -1865,7 +1865,7 @@ describe API::Users, :do_not_mock_admin_mode do
context "when unauthenticated" do
it "returns authentication error" do
get api("/user/emails")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -1876,7 +1876,7 @@ describe API::Users, :do_not_mock_admin_mode do
get api("/user/emails", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first["email"]).to eq(email.email)
@@ -1896,13 +1896,13 @@ describe API::Users, :do_not_mock_admin_mode do
user.emails << email
user.save
get api("/user/emails/#{email.id}", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response["email"]).to eq(email.email)
end
it "returns 404 Not Found within invalid ID" do
get api("/user/emails/42", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Email Not Found')
end
@@ -1911,14 +1911,14 @@ describe API::Users, :do_not_mock_admin_mode do
user.save
admin
get api("/user/emails/#{email.id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Email Not Found')
end
it "returns 404 for invalid ID" do
get api("/users/emails/ASDF", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
context "scopes" do
@@ -1935,18 +1935,18 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
post api("/user/emails", user), params: email_attrs
end.to change { user.emails.count }.by(1)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
end
it "returns a 401 error if unauthorized" do
post api("/user/emails"), params: { email: 'some email' }
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
it "does not create email with invalid email" do
post api("/user/emails", user), params: {}
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('email is missing')
end
end
@@ -1959,7 +1959,7 @@ describe API::Users, :do_not_mock_admin_mode do
expect do
delete api("/user/emails/#{email.id}", user)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end.to change { user.emails.count}.by(-1)
end
@@ -1970,7 +1970,7 @@ describe API::Users, :do_not_mock_admin_mode do
it "returns 404 if email ID not found" do
delete api("/user/emails/42", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Email Not Found')
end
@@ -1978,20 +1978,20 @@ describe API::Users, :do_not_mock_admin_mode do
user.emails << email
user.save
delete api("/user/emails/#{email.id}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
it "returns 400 for invalid ID" do
delete api("/user/emails/ASDF", admin)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
end
context 'activate and deactivate' do
shared_examples '404' do
it 'returns 404' do
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
end
@@ -2001,7 +2001,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'is not authorized to perform the action' do
post api("/users/#{user.id}/activate", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -2014,7 +2014,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'activates a deactivated user' do
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('active')
end
end
@@ -2027,7 +2027,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 201' do
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('active')
end
end
@@ -2040,7 +2040,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 403' do
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden - A blocked user must be unblocked to be activated')
expect(user.reload.state).to eq('blocked')
end
@@ -2054,7 +2054,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 403' do
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden - A blocked user must be unblocked to be activated')
expect(user.reload.state).to eq('ldap_blocked')
end
@@ -2075,7 +2075,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'is not authorized to perform the action' do
post api("/users/#{user.id}/deactivate", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -2092,7 +2092,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'deactivates an active user' do
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('deactivated')
end
end
@@ -2105,7 +2105,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'does not deactivate an active user' do
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq("403 Forbidden - The user you are trying to deactivate has been active in the past #{::User::MINIMUM_INACTIVE_DAYS} days and cannot be deactivated")
expect(user.reload.state).to eq('active')
end
@@ -2120,7 +2120,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 201' do
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('deactivated')
end
end
@@ -2133,7 +2133,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 403' do
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden - A blocked user cannot be deactivated by the API')
expect(user.reload.state).to eq('blocked')
end
@@ -2147,7 +2147,7 @@ describe API::Users, :do_not_mock_admin_mode do
end
it 'returns 403' do
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden - A blocked user cannot be deactivated by the API')
expect(user.reload.state).to eq('ldap_blocked')
end
@@ -2171,25 +2171,25 @@ describe API::Users, :do_not_mock_admin_mode do
it 'blocks existing user' do
post api("/users/#{user.id}/block", admin)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('blocked')
end
it 'does not re-block ldap blocked users' do
post api("/users/#{ldap_blocked_user.id}/block", admin)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(ldap_blocked_user.reload.state).to eq('ldap_blocked')
end
it 'does not be available for non admin users' do
post api("/users/#{user.id}/block", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(user.reload.state).to eq('active')
end
it 'returns a 404 error if user id not found' do
post api('/users/0/block', admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
end
@@ -2204,44 +2204,44 @@ describe API::Users, :do_not_mock_admin_mode do
it 'unblocks existing user' do
post api("/users/#{user.id}/unblock", admin)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(user.reload.state).to eq('active')
end
it 'unblocks a blocked user' do
post api("/users/#{blocked_user.id}/unblock", admin)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(blocked_user.reload.state).to eq('active')
end
it 'does not unblock ldap blocked users' do
post api("/users/#{ldap_blocked_user.id}/unblock", admin)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(ldap_blocked_user.reload.state).to eq('ldap_blocked')
end
it 'does not unblock deactivated users' do
post api("/users/#{deactivated_user.id}/unblock", admin)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(deactivated_user.reload.state).to eq('deactivated')
end
it 'is not available for non admin users' do
post api("/users/#{user.id}/unblock", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(user.reload.state).to eq('active')
end
it 'returns a 404 error if user id not found' do
post api('/users/0/block', admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it "returns a 404 for invalid ID" do
post api("/users/ASDF/block", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -2330,7 +2330,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'has no permission' do
get api("/user/activities", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -2382,7 +2382,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'renders errors when the status was invalid' do
put api('/user/status', user), params: { emoji: 'does not exist', message: 'hello world' }
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['emoji']).to be_present
end
@@ -2404,21 +2404,21 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns a 404 error if user not found' do
get api("/users/#{not_existing_user_id}/impersonation_tokens", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns a 403 error when authenticated as normal user' do
get api("/users/#{not_existing_user_id}/impersonation_tokens", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden')
end
it 'returns an array of all impersonated tokens' do
get api("/users/#{user.id}/impersonation_tokens", admin)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(2)
@@ -2427,7 +2427,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns an array of active impersonation tokens if state active' do
get api("/users/#{user.id}/impersonation_tokens?state=active", admin)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
@@ -2437,7 +2437,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns an array of inactive personal access tokens if active is set to false' do
get api("/users/#{user.id}/impersonation_tokens?state=inactive", admin)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
expect(json_response).to all(include('active' => false))
@@ -2453,7 +2453,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns validation error if impersonation token misses some attributes' do
post api("/users/#{user.id}/impersonation_tokens", admin)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('name is missing')
end
@@ -2464,7 +2464,7 @@ describe API::Users, :do_not_mock_admin_mode do
expires_at: expires_at
}
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
@@ -2475,7 +2475,7 @@ describe API::Users, :do_not_mock_admin_mode do
expires_at: expires_at
}
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden')
end
@@ -2488,7 +2488,7 @@ describe API::Users, :do_not_mock_admin_mode do
impersonation: impersonation
}
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq(name)
expect(json_response['scopes']).to eq(scopes)
expect(json_response['expires_at']).to eq(expires_at)
@@ -2508,35 +2508,35 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns 404 error if user not found' do
get api("/users/#{not_existing_user_id}/impersonation_tokens/1", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns a 404 error if impersonation token not found' do
get api("/users/#{user.id}/impersonation_tokens/#{not_existing_pat_id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Impersonation Token Not Found')
end
it 'returns a 404 error if token is not impersonation token' do
get api("/users/#{user.id}/impersonation_tokens/#{personal_access_token.id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Impersonation Token Not Found')
end
it 'returns a 403 error when authenticated as normal user' do
get api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden')
end
it 'returns an impersonation token' do
get api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['token']).not_to be_present
expect(json_response['impersonation']).to be_truthy
end
@@ -2549,28 +2549,28 @@ describe API::Users, :do_not_mock_admin_mode do
it 'returns a 404 error if user not found' do
delete api("/users/#{not_existing_user_id}/impersonation_tokens/1", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns a 404 error if impersonation token not found' do
delete api("/users/#{user.id}/impersonation_tokens/#{not_existing_pat_id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Impersonation Token Not Found')
end
it 'returns a 404 error if token is not impersonation token' do
delete api("/users/#{user.id}/impersonation_tokens/#{personal_access_token.id}", admin)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Impersonation Token Not Found')
end
it 'returns a 403 error when authenticated as normal user' do
delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", user)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response['message']).to eq('403 Forbidden')
end
@@ -2581,7 +2581,7 @@ describe API::Users, :do_not_mock_admin_mode do
it 'revokes a impersonation token' do
delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
expect(impersonation_token.revoked).to be_falsey
expect(impersonation_token.reload.revoked).to be_truthy
end
diff --git a/spec/requests/api/variables_spec.rb b/spec/requests/api/variables_spec.rb
index dfecd43cbfa..f209a1d2e6e 100644
--- a/spec/requests/api/variables_spec.rb
+++ b/spec/requests/api/variables_spec.rb
@@ -15,7 +15,7 @@ describe API::Variables do
it 'returns project variables' do
get api("/projects/#{project.id}/variables", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a(Array)
end
end
@@ -24,7 +24,7 @@ describe API::Variables do
it 'does not return project variables' do
get api("/projects/#{project.id}/variables", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -32,7 +32,7 @@ describe API::Variables do
it 'does not return project variables' do
get api("/projects/#{project.id}/variables")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -42,7 +42,7 @@ describe API::Variables do
it 'returns project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}", user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['value']).to eq(variable.value)
expect(json_response['protected']).to eq(variable.protected?)
expect(json_response['masked']).to eq(variable.masked?)
@@ -52,7 +52,7 @@ describe API::Variables do
it 'responds with 404 Not Found if requesting non-existing variable' do
get api("/projects/#{project.id}/variables/non_existing_variable", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -60,7 +60,7 @@ describe API::Variables do
it 'does not return project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -68,7 +68,7 @@ describe API::Variables do
it 'does not return project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -80,7 +80,7 @@ describe API::Variables do
post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true, masked: true }
end.to change {project.variables.count}.by(1)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['key']).to eq('TEST_VARIABLE_2')
expect(json_response['value']).to eq('PROTECTED_VALUE_2')
expect(json_response['protected']).to be_truthy
@@ -93,7 +93,7 @@ describe API::Variables do
post api("/projects/#{project.id}/variables", user), params: { variable_type: 'file', key: 'TEST_VARIABLE_2', value: 'VALUE_2' }
end.to change {project.variables.count}.by(1)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['key']).to eq('TEST_VARIABLE_2')
expect(json_response['value']).to eq('VALUE_2')
expect(json_response['protected']).to be_falsey
@@ -106,7 +106,7 @@ describe API::Variables do
post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
end.to change {project.variables.count}.by(0)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
end
it 'creates variable with a specific environment scope' do
@@ -114,7 +114,7 @@ describe API::Variables do
post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2', environment_scope: 'review/*' }
end.to change { project.variables.reload.count }.by(1)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['key']).to eq('TEST_VARIABLE_2')
expect(json_response['value']).to eq('VALUE_2')
expect(json_response['environment_scope']).to eq('review/*')
@@ -127,7 +127,7 @@ describe API::Variables do
post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2', environment_scope: 'review/*' }
end.to change { project.variables.reload.count }.by(1)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response['key']).to eq(variable.key)
expect(json_response['value']).to eq('VALUE_2')
expect(json_response['environment_scope']).to eq('review/*')
@@ -138,7 +138,7 @@ describe API::Variables do
it 'does not create variable' do
post api("/projects/#{project.id}/variables", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -146,7 +146,7 @@ describe API::Variables do
it 'does not create variable' do
post api("/projects/#{project.id}/variables")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -161,7 +161,7 @@ describe API::Variables do
updated_variable = project.variables.reload.first
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(value_before).to eq(variable.value)
expect(updated_variable.value).to eq('VALUE_1_UP')
expect(updated_variable).to be_protected
@@ -171,7 +171,7 @@ describe API::Variables do
it 'responds with 404 Not Found if requesting non-existing variable' do
put api("/projects/#{project.id}/variables/non_existing_variable", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -179,7 +179,7 @@ describe API::Variables do
it 'does not update variable' do
put api("/projects/#{project.id}/variables/#{variable.key}", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -187,7 +187,7 @@ describe API::Variables do
it 'does not update variable' do
put api("/projects/#{project.id}/variables/#{variable.key}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
@@ -198,14 +198,14 @@ describe API::Variables do
expect do
delete api("/projects/#{project.id}/variables/#{variable.key}", user)
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end.to change {project.variables.count}.by(-1)
end
it 'responds with 404 Not Found if requesting non-existing variable' do
delete api("/projects/#{project.id}/variables/non_existing_variable", user)
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -213,7 +213,7 @@ describe API::Variables do
it 'does not delete variable' do
delete api("/projects/#{project.id}/variables/#{variable.key}", user2)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
@@ -221,7 +221,7 @@ describe API::Variables do
it 'does not delete variable' do
delete api("/projects/#{project.id}/variables/#{variable.key}")
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
diff --git a/spec/requests/api/version_spec.rb b/spec/requests/api/version_spec.rb
index 7d81170687a..9eb8c03e273 100644
--- a/spec/requests/api/version_spec.rb
+++ b/spec/requests/api/version_spec.rb
@@ -8,7 +8,7 @@ describe API::Version do
it 'returns authentication error' do
get api('/version')
- expect(response).to have_gitlab_http_status(401)
+ expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -51,13 +51,13 @@ describe API::Version do
it 'returns authorization error' do
get api('/version', personal_access_token: personal_access_token)
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
def expect_version
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response['version']).to eq(Gitlab::VERSION)
expect(json_response['revision']).to eq(Gitlab.revision)
end
diff --git a/spec/requests/api/wikis_spec.rb b/spec/requests/api/wikis_spec.rb
index 2e0b7a30480..7bd9a178a8d 100644
--- a/spec/requests/api/wikis_spec.rb
+++ b/spec/requests/api/wikis_spec.rb
@@ -32,7 +32,7 @@ describe API::Wikis do
it 'returns the list of wiki pages without content' do
get api(url, user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2)
json_response.each_with_index do |page, index|
@@ -45,7 +45,7 @@ describe API::Wikis do
it 'returns the list of wiki pages with content' do
get api(url, user), params: { with_content: 1 }
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(2)
json_response.each_with_index do |page, index|
@@ -60,14 +60,14 @@ describe API::Wikis do
it 'return the empty list of wiki pages' do
get api(url, user)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(0)
end
end
shared_examples_for 'returns wiki page' do
it 'returns the wiki page' do
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(page.content)
@@ -80,7 +80,7 @@ describe API::Wikis do
it 'creates the wiki page' do
post(api(url, user), params: payload)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(payload[:content])
@@ -95,7 +95,7 @@ describe API::Wikis do
post(api(url, user), params: payload)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response.size).to eq(1)
expect(json_response['error']).to eq("#{part} is missing")
end
@@ -106,7 +106,7 @@ describe API::Wikis do
it 'updates the wiki page' do
put(api(url, user), params: payload)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(payload[:content])
@@ -120,14 +120,14 @@ describe API::Wikis do
put(api(url, user), params: payload)
- expect(response).to have_gitlab_http_status(200)
+ expect(response).to have_gitlab_http_status(:ok)
end
end
end
shared_examples_for '403 Forbidden' do
it 'returns 403 Forbidden' do
- expect(response).to have_gitlab_http_status(403)
+ expect(response).to have_gitlab_http_status(:forbidden)
expect(json_response.size).to eq(1)
expect(json_response['message']).to eq('403 Forbidden')
end
@@ -135,7 +135,7 @@ describe API::Wikis do
shared_examples_for '404 Wiki Page Not Found' do
it 'returns 404 Wiki Page Not Found' do
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response.size).to eq(1)
expect(json_response['message']).to eq('404 Wiki Page Not Found')
end
@@ -143,7 +143,7 @@ describe API::Wikis do
shared_examples_for '404 Project Not Found' do
it 'returns 404 Project Not Found' do
- expect(response).to have_gitlab_http_status(404)
+ expect(response).to have_gitlab_http_status(:not_found)
expect(json_response.size).to eq(1)
expect(json_response['message']).to eq('404 Project Not Found')
end
@@ -151,7 +151,7 @@ describe API::Wikis do
shared_examples_for '204 No Content' do
it 'returns 204 No Content' do
- expect(response).to have_gitlab_http_status(204)
+ expect(response).to have_gitlab_http_status(:no_content)
end
end
@@ -161,7 +161,7 @@ describe API::Wikis do
workhorse_post_with_file(api(url, user), file_key: :file, params: payload)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq result_hash.deep_stringify_keys
end
@@ -170,7 +170,7 @@ describe API::Wikis do
post(api(url, user), params: payload)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response.size).to eq(1)
expect(json_response['error']).to eq('file is missing')
end
@@ -180,7 +180,7 @@ describe API::Wikis do
post(api(url, user), params: payload)
- expect(response).to have_gitlab_http_status(400)
+ expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response.size).to eq(1)
expect(json_response['error']).to eq('file is invalid')
end
@@ -190,7 +190,7 @@ describe API::Wikis do
post(api(url, user), params: payload)
- expect(response).to have_gitlab_http_status(201)
+ expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq result_hash.deep_stringify_keys
end
end