Commit bbaf2bb0 authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent e9c2bf26
...@@ -331,26 +331,13 @@ RSpec/MissingExampleGroupArgument: ...@@ -331,26 +331,13 @@ RSpec/MissingExampleGroupArgument:
RSpec/UnspecifiedException: RSpec/UnspecifiedException:
Enabled: false Enabled: false
# Work in progress. See https://gitlab.com/gitlab-org/gitlab/issues/196163
RSpec/HaveGitlabHttpStatus: RSpec/HaveGitlabHttpStatus:
Enabled: true Enabled: true
Exclude: Exclude:
- 'spec/support/matchers/have_gitlab_http_status.rb' - 'spec/support/matchers/have_gitlab_http_status.rb'
Include: Include:
- 'spec/support/**/*' - 'spec/**/*'
- 'ee/spec/support/**/*' - 'ee/spec/**/*'
- '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'
Style/MultilineWhenThen: Style/MultilineWhenThen:
Enabled: false Enabled: false
......
...@@ -61,9 +61,11 @@ class SnippetsFinder < UnionFinder ...@@ -61,9 +61,11 @@ class SnippetsFinder < UnionFinder
def execute def execute
# The snippet query can be expensive, therefore if the # The snippet query can be expensive, therefore if the
# author or project params have been passed and they don't # 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 author.nil? && params[:author].present?
return Snippet.none if project.nil? && params[:project].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 = init_collection
items = by_ids(items) items = by_ids(items)
......
...@@ -6,4 +6,5 @@ ...@@ -6,4 +6,5 @@
= icon('rss') = icon('rss')
.content_list.project-activity{ :"data-href" => activity_project_path(@project) } .content_list.project-activity{ :"data-href" => activity_project_path(@project) }
= spinner .loading
.spinner.spinner-md
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
.save-project-loader.hide .save-project-loader.hide
.center .center
%h2 %h2
%i.fa.fa-spinner.fa-spin .spinner.spinner-md.align-text-bottom
= _('Saving project.') = _('Saving project.')
%p= _('Please wait a moment, this page will automatically refresh when ready.') %p= _('Please wait a moment, this page will automatically refresh when ready.')
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
.save-project-loader.d-none .save-project-loader.d-none
.center .center
%h2 %h2
%i.fa.fa-spinner.fa-spin .spinner.spinner-md.align-text-bottom
= s_('ProjectsNew|Creating project & repository.') = s_('ProjectsNew|Creating project & repository.')
%p %p
= s_('ProjectsNew|Please wait a moment, this page will automatically refresh when ready.') = s_('ProjectsNew|Please wait a moment, this page will automatically refresh when ready.')
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
.tabs-holder .tabs-holder
%ul.pipelines-tabs.nav-links.no-top.no-bottom.mobile-separator.nav.nav-tabs %ul.pipelines-tabs.nav-links.no-top.no-bottom.mobile-separator.nav.nav-tabs
%li.js-pipeline-tab-link %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') = _('Pipeline')
%li.js-builds-tab-link %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 = link_to builds_project_pipeline_path(@project, @pipeline), data: { target: '#js-tab-builds', action: 'builds', toggle: 'tab' }, class: 'builds-tab' do
......
---
title: Update loader for various project views
merge_request: 25755
author: Phellipe K Ribeiro
type: other
---
title: Generate proper link for Pipeline tab
merge_request: 26193
author:
type: fixed
---
title: Improve SnippetsFinder performance with disabled project snippets
merge_request: 26295
author:
type: performance
# 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
...@@ -4831,16 +4831,16 @@ enum MilestoneStateEnum { ...@@ -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 { 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 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 before
} }
......
...@@ -24550,20 +24550,20 @@ ...@@ -24550,20 +24550,20 @@
{ {
"kind": "ENUM", "kind": "ENUM",
"name": "MoveType", "name": "MoveType",
"description": "The position the adjacent object should be moved.", "description": "The position to which the adjacent object should be moved",
"fields": null, "fields": null,
"inputFields": null, "inputFields": null,
"interfaces": null, "interfaces": null,
"enumValues": [ "enumValues": [
{ {
"name": "before", "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, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
}, },
{ {
"name": "after", "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, "isDeprecated": false,
"deprecationReason": null "deprecationReason": null
} }
......
...@@ -15,10 +15,6 @@ limits](https://about.gitlab.com/handbook/product/#introducing-application-limit ...@@ -15,10 +15,6 @@ limits](https://about.gitlab.com/handbook/product/#introducing-application-limit
## Development ## 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 ### Insert database plan limits
In the `plan_limits` table, you have to create a new column and insert the 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 ...@@ -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 that the count of the records for the current model does not exceed the defined
limit. limit.
NOTE: **Note:** The name (pluralized) of the plan limit introduced in the NOTE: **Note:** You must specify the limit scope of the object being validated
database (`project_hooks`) must correspond to the name of the model we are and the limit name if it's different from the pluralized model name.
validating (`ProjectHook`).
```ruby ```ruby
class ProjectHook class ProjectHook
include Limitable 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 end
``` ```
...@@ -8,6 +8,7 @@ class GitlabDanger ...@@ -8,6 +8,7 @@ class GitlabDanger
duplicate_yarn_dependencies duplicate_yarn_dependencies
prettier prettier
eslint eslint
karma
database database
commit_messages commit_messages
].freeze ].freeze
......
...@@ -12051,9 +12051,6 @@ msgstr "" ...@@ -12051,9 +12051,6 @@ msgstr ""
msgid "Maximum number of comments exceeded" msgid "Maximum number of comments exceeded"
msgstr "" msgstr ""
msgid "Maximum number of group hooks (%{count}) exceeded"
msgstr ""
msgid "Maximum number of mirrors that can be synchronizing at the same time." msgid "Maximum number of mirrors that can be synchronizing at the same time."
msgstr "" msgstr ""
......
...@@ -284,6 +284,17 @@ describe SnippetsFinder do ...@@ -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) expect(described_class.new(user).execute).to contain_exactly(private_personal_snippet, internal_personal_snippet, public_personal_snippet)
end end
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 end
it_behaves_like 'snippet visibility' it_behaves_like 'snippet visibility'
......
...@@ -9,7 +9,7 @@ describe GitlabDanger do ...@@ -9,7 +9,7 @@ describe GitlabDanger do
describe '.local_warning_message' do describe '.local_warning_message' do
it 'returns an informational message with rules that can run' 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
end end
......
...@@ -61,7 +61,7 @@ describe API::Tags do ...@@ -61,7 +61,7 @@ describe API::Tags do
it 'only returns searched tags' do it 'only returns searched tags' do
get api("#{route}", user), params: { search: 'v1.1.0' } 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(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(1) expect(json_response.size).to eq(1)
...@@ -73,7 +73,7 @@ describe API::Tags do ...@@ -73,7 +73,7 @@ describe API::Tags do
it 'returns the repository tags' do it 'returns the repository tags' do
get api(route, current_user) 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 match_response_schema('public_api/v4/tags')
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response.map { |r| r['name'] }).to include(tag_name) expect(json_response.map { |r| r['name'] }).to include(tag_name)
...@@ -133,7 +133,7 @@ describe API::Tags do ...@@ -133,7 +133,7 @@ describe API::Tags do
it 'returns an array of project tags with release info' do it 'returns an array of project tags with release info' do
get api(route, user) 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 match_response_schema('public_api/v4/tags')
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
...@@ -151,7 +151,7 @@ describe API::Tags do ...@@ -151,7 +151,7 @@ describe API::Tags do
it 'returns the repository branch' do it 'returns the repository branch' do
get api(route, current_user) 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(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
end end
...@@ -214,7 +214,7 @@ describe API::Tags do ...@@ -214,7 +214,7 @@ describe API::Tags do
it 'creates a new tag' do it 'creates a new tag' do
post api(route, current_user), params: { tag_name: tag_name, ref: 'master' } 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(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
end end
...@@ -269,26 +269,26 @@ describe API::Tags do ...@@ -269,26 +269,26 @@ describe API::Tags do
it 'returns 400 if tag name is invalid' do it 'returns 400 if tag name is invalid' do
post api(route, current_user), params: { tag_name: 'new design', ref: 'master' } 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') expect(json_response['message']).to eq('Tag name invalid')
end end
it 'returns 400 if tag already exists' do it 'returns 400 if tag already exists' do
post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' } post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/tag') expect(response).to match_response_schema('public_api/v4/tag')
post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' } post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Tag new_design1 already exists') expect(json_response['message']).to eq('Tag new_design1 already exists')
end end
it 'returns 400 if ref name is invalid' do it 'returns 400 if ref name is invalid' do
post api(route, current_user), params: { tag_name: 'new_design3', ref: 'foo' } 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') expect(json_response['message']).to eq('Target foo is invalid')
end end
...@@ -296,7 +296,7 @@ describe API::Tags do ...@@ -296,7 +296,7 @@ describe API::Tags do
it 'creates a new tag' do it 'creates a new tag' do
post api(route, current_user), params: { tag_name: tag_name, ref: 'master', release_description: 'Wow' } 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(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq(tag_name) expect(json_response['name']).to eq(tag_name)
expect(json_response['release']['description']).to eq('Wow') expect(json_response['release']['description']).to eq('Wow')
...@@ -315,7 +315,7 @@ describe API::Tags do ...@@ -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' } 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(response).to match_response_schema('public_api/v4/tag')
expect(json_response['name']).to eq('v7.1.0') expect(json_response['name']).to eq('v7.1.0')
expect(json_response['message']).to eq('Release 7.1.0') expect(json_response['message']).to eq('Release 7.1.0')
...@@ -337,7 +337,7 @@ describe API::Tags do ...@@ -337,7 +337,7 @@ describe API::Tags do
it 'deletes a tag' do it 'deletes a tag' do
delete api(route, current_user) delete api(route, current_user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -383,7 +383,7 @@ describe API::Tags do ...@@ -383,7 +383,7 @@ describe API::Tags do
it 'creates description for existing git tag' do it 'creates description for existing git tag' do
post api(route, user), params: { description: description } 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(response).to match_response_schema('public_api/v4/release/tag_release')
expect(json_response['tag_name']).to eq(tag_name) expect(json_response['tag_name']).to eq(tag_name)
expect(json_response['description']).to eq(description) expect(json_response['description']).to eq(description)
...@@ -424,7 +424,7 @@ describe API::Tags do ...@@ -424,7 +424,7 @@ describe API::Tags do
it 'returns 409 if there is already a release' do it 'returns 409 if there is already a release' do
post api(route, user), params: { description: description } 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') expect(json_response['message']).to eq('Release already exists')
end end
end end
...@@ -449,7 +449,7 @@ describe API::Tags do ...@@ -449,7 +449,7 @@ describe API::Tags do
it 'updates the release description' do it 'updates the release description' do
put api(route, current_user), params: { description: new_description } 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['tag_name']).to eq(tag_name)
expect(json_response['description']).to eq(new_description) expect(json_response['description']).to eq(new_description)
end end
......
...@@ -57,7 +57,7 @@ describe 'task completion status response' do ...@@ -57,7 +57,7 @@ describe 'task completion status response' do
get api("#{path}?iids[]=#{taskable.iid}", user) get api("#{path}?iids[]=#{taskable.iid}", user)
end 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 it 'returns the expected results' do
expect(json_response).to be_an Array expect(json_response).to be_an Array
......
...@@ -25,7 +25,7 @@ describe API::Templates do ...@@ -25,7 +25,7 @@ describe API::Templates do
it 'returns a list of available gitignore templates' do it 'returns a list of available gitignore templates' do
get api('/templates/gitignores') 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(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to be > 15 expect(json_response.size).to be > 15
...@@ -36,7 +36,7 @@ describe API::Templates do ...@@ -36,7 +36,7 @@ describe API::Templates do
it 'returns a list of available gitlab_ci_ymls' do it 'returns a list of available gitlab_ci_ymls' do
get api('/templates/gitlab_ci_ymls') 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(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['name']).not_to be_nil expect(json_response.first['name']).not_to be_nil
...@@ -47,7 +47,7 @@ describe API::Templates do ...@@ -47,7 +47,7 @@ describe API::Templates do
it 'adds a disclaimer on the top' do it 'adds a disclaimer on the top' do
get api('/templates/gitlab_ci_ymls/Ruby') 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,") expect(json_response['content']).to start_with("# This file is a template,")
end end
end end
...@@ -58,7 +58,7 @@ describe API::Templates do ...@@ -58,7 +58,7 @@ describe API::Templates do
end end
it 'returns a license template' do 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['key']).to eq('mit')
expect(json_response['name']).to eq('MIT License') expect(json_response['name']).to eq('MIT License')
...@@ -78,7 +78,7 @@ describe API::Templates do ...@@ -78,7 +78,7 @@ describe API::Templates do
it 'returns a list of available license templates' do it 'returns a list of available license templates' do
get api('/templates/licenses') 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(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(12) expect(json_response.size).to eq(12)
...@@ -90,7 +90,7 @@ describe API::Templates do ...@@ -90,7 +90,7 @@ describe API::Templates do
it 'returns a list of available popular license templates' do it 'returns a list of available popular license templates' do
get api('/templates/licenses?popular=1') 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(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.size).to eq(3) expect(json_response.size).to eq(3)
...@@ -173,7 +173,7 @@ describe API::Templates do ...@@ -173,7 +173,7 @@ describe API::Templates do
let(:license_type) { 'muth-over9000' } let(:license_type) { 'muth-over9000' }
it 'returns a 404' do it 'returns a 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -185,7 +185,7 @@ describe API::Templates do ...@@ -185,7 +185,7 @@ describe API::Templates do
it 'replaces the copyright owner placeholder with the name of the current user' do it 'replaces the copyright owner placeholder with the name of the current user' do
get api('/templates/licenses/mit', user) 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}") expect(json_response['content']).to include("Copyright (c) #{Time.now.year} #{user.name}")
end end
end end
......
...@@ -166,7 +166,7 @@ describe API::Todos do ...@@ -166,7 +166,7 @@ describe API::Todos do
it 'returns authentication error' do it 'returns authentication error' do
post api("/todos/#{pending_1.id}/mark_as_done") 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
end end
...@@ -174,7 +174,7 @@ describe API::Todos do ...@@ -174,7 +174,7 @@ describe API::Todos do
it 'marks a todo as done' do it 'marks a todo as done' do
post api("/todos/#{pending_1.id}/mark_as_done", john_doe) 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['id']).to eq(pending_1.id)
expect(json_response['state']).to eq('done') expect(json_response['state']).to eq('done')
expect(pending_1.reload).to be_done expect(pending_1.reload).to be_done
...@@ -199,7 +199,7 @@ describe API::Todos do ...@@ -199,7 +199,7 @@ describe API::Todos do
it 'returns authentication error' do it 'returns authentication error' do
post api('/todos/mark_as_done') post api('/todos/mark_as_done')
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -207,7 +207,7 @@ describe API::Todos do ...@@ -207,7 +207,7 @@ describe API::Todos do
it 'marks all todos as done' do it 'marks all todos as done' do
post api('/todos/mark_as_done', john_doe) 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_1.reload).to be_done
expect(pending_2.reload).to be_done expect(pending_2.reload).to be_done
expect(pending_3.reload).to be_done expect(pending_3.reload).to be_done
...@@ -258,9 +258,9 @@ describe API::Todos do ...@@ -258,9 +258,9 @@ describe API::Todos do
post api("/projects/#{project_1.id}/#{issuable_type}/#{issuable.iid}/todo", guest) post api("/projects/#{project_1.id}/#{issuable_type}/#{issuable.iid}/todo", guest)
if issuable_type == 'merge_requests' if issuable_type == 'merge_requests'
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
else else
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -31,13 +31,13 @@ describe API::Triggers do ...@@ -31,13 +31,13 @@ describe API::Triggers do
it 'returns bad request if token is missing' do it 'returns bad request if token is missing' do
post api("/projects/#{project.id}/trigger/pipeline"), params: { ref: 'master' } 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 end
it 'returns not found if project is not found' do it 'returns not found if project is not found' do
post api('/projects/0/trigger/pipeline'), params: options.merge(ref: 'master') 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
end end
...@@ -47,7 +47,7 @@ describe API::Triggers do ...@@ -47,7 +47,7 @@ describe API::Triggers do
it 'creates pipeline' do it 'creates pipeline' do
post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'master') 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) expect(json_response).to include('id' => pipeline.id)
pipeline.builds.reload pipeline.builds.reload
expect(pipeline.builds.pending.size).to eq(2) expect(pipeline.builds.pending.size).to eq(2)
...@@ -57,7 +57,7 @@ describe API::Triggers do ...@@ -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 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') 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"]) expect(json_response['message']).to eq('base' => ["Reference not found"])
end end
...@@ -69,21 +69,21 @@ describe API::Triggers do ...@@ -69,21 +69,21 @@ describe API::Triggers do
it 'validates variables to be a hash' do it 'validates variables to be a hash' do
post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: 'value', ref: 'master') 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') expect(json_response['error']).to eq('variables is invalid')
end end
it 'validates variables needs to be a map of key-valued strings' do 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') 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') expect(json_response['message']).to eq('variables needs to be a map of key-valued strings')
end end
it 'creates trigger request with variables' do it 'creates trigger request with variables' do
post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: variables, ref: 'master') 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) expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables)
end end
end end
...@@ -93,7 +93,7 @@ describe API::Triggers do ...@@ -93,7 +93,7 @@ describe API::Triggers do
it 'does not leak the presence of project when token is for different project' 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' } 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 end
it 'creates builds from the ref given in the URL, not in the body' do it 'creates builds from the ref given in the URL, not in the body' do
...@@ -101,7 +101,7 @@ describe API::Triggers 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' } 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) 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 end
context 'when ref contains a dot' do context 'when ref contains a dot' do
...@@ -112,7 +112,7 @@ describe API::Triggers 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' } 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) 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 end
end end
...@@ -123,7 +123,7 @@ describe API::Triggers do ...@@ -123,7 +123,7 @@ describe API::Triggers do
it 'returns a list of triggers with tokens exposed correctly' do it 'returns a list of triggers with tokens exposed correctly' do
get api("/projects/#{project.id}/triggers", user) 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(response).to include_pagination_headers
expect(json_response).to be_a(Array) expect(json_response).to be_a(Array)
...@@ -137,7 +137,7 @@ describe API::Triggers do ...@@ -137,7 +137,7 @@ describe API::Triggers do
it 'does not return triggers list' do it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers", user2) 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
end end
...@@ -145,7 +145,7 @@ describe API::Triggers do ...@@ -145,7 +145,7 @@ describe API::Triggers do
it 'does not return triggers list' do it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers") 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 end
end end
...@@ -155,14 +155,14 @@ describe API::Triggers do ...@@ -155,14 +155,14 @@ describe API::Triggers do
it 'returns trigger details' do it 'returns trigger details' do
get api("/projects/#{project.id}/triggers/#{trigger.id}", user) 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) expect(json_response).to be_a(Hash)
end end
it 'responds with 404 Not Found if requesting non-existing trigger' do it 'responds with 404 Not Found if requesting non-existing trigger' do
get api("/projects/#{project.id}/triggers/-5", user) 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
end end
...@@ -170,7 +170,7 @@ describe API::Triggers do ...@@ -170,7 +170,7 @@ describe API::Triggers do
it 'does not return triggers list' do it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers/#{trigger.id}", user2) 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
end end
...@@ -178,7 +178,7 @@ describe API::Triggers do ...@@ -178,7 +178,7 @@ describe API::Triggers do
it 'does not return triggers list' do it 'does not return triggers list' do
get api("/projects/#{project.id}/triggers/#{trigger.id}") 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 end
end end
...@@ -192,7 +192,7 @@ describe API::Triggers do ...@@ -192,7 +192,7 @@ describe API::Triggers do
params: { description: 'trigger' } params: { description: 'trigger' }
end.to change {project.triggers.count}.by(1) 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') expect(json_response).to include('description' => 'trigger')
end end
end end
...@@ -211,7 +211,7 @@ describe API::Triggers do ...@@ -211,7 +211,7 @@ describe API::Triggers do
post api("/projects/#{project.id}/triggers", user2), post api("/projects/#{project.id}/triggers", user2),
params: { description: 'trigger' } params: { description: 'trigger' }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -220,7 +220,7 @@ describe API::Triggers do ...@@ -220,7 +220,7 @@ describe API::Triggers do
post api("/projects/#{project.id}/triggers"), post api("/projects/#{project.id}/triggers"),
params: { description: 'trigger' } params: { description: 'trigger' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
end end
...@@ -233,7 +233,7 @@ describe API::Triggers do ...@@ -233,7 +233,7 @@ describe API::Triggers do
put api("/projects/#{project.id}/triggers/#{trigger.id}", user), put api("/projects/#{project.id}/triggers/#{trigger.id}", user),
params: { description: new_description } params: { description: new_description }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to include('description' => new_description) expect(json_response).to include('description' => new_description)
expect(trigger.reload.description).to eq(new_description) expect(trigger.reload.description).to eq(new_description)
end end
...@@ -243,7 +243,7 @@ describe API::Triggers do ...@@ -243,7 +243,7 @@ describe API::Triggers do
it 'does not update trigger' do it 'does not update trigger' do
put api("/projects/#{project.id}/triggers/#{trigger.id}", user2) 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
end end
...@@ -251,7 +251,7 @@ describe API::Triggers do ...@@ -251,7 +251,7 @@ describe API::Triggers do
it 'does not update trigger' do it 'does not update trigger' do
put api("/projects/#{project.id}/triggers/#{trigger.id}") 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 end
end end
...@@ -262,14 +262,14 @@ describe API::Triggers do ...@@ -262,14 +262,14 @@ describe API::Triggers do
expect do expect do
delete api("/projects/#{project.id}/triggers/#{trigger.id}", user) 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.to change {project.triggers.count}.by(-1)
end end
it 'responds with 404 Not Found if requesting non-existing trigger' do it 'responds with 404 Not Found if requesting non-existing trigger' do
delete api("/projects/#{project.id}/triggers/-5", user) 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 end
it_behaves_like '412 response' do it_behaves_like '412 response' do
...@@ -281,7 +281,7 @@ describe API::Triggers do ...@@ -281,7 +281,7 @@ describe API::Triggers do
it 'does not delete trigger' do it 'does not delete trigger' do
delete api("/projects/#{project.id}/triggers/#{trigger.id}", user2) 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
end end
...@@ -289,7 +289,7 @@ describe API::Triggers do ...@@ -289,7 +289,7 @@ describe API::Triggers do
it 'does not delete trigger' do it 'does not delete trigger' do
delete api("/projects/#{project.id}/triggers/#{trigger.id}") 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 end
end end
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ describe API::Variables do ...@@ -15,7 +15,7 @@ describe API::Variables do
it 'returns project variables' do it 'returns project variables' do
get api("/projects/#{project.id}/variables", user) 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) expect(json_response).to be_a(Array)
end end
end end
...@@ -24,7 +24,7 @@ describe API::Variables do ...@@ -24,7 +24,7 @@ describe API::Variables do
it 'does not return project variables' do it 'does not return project variables' do
get api("/projects/#{project.id}/variables", user2) 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
end end
...@@ -32,7 +32,7 @@ describe API::Variables do ...@@ -32,7 +32,7 @@ describe API::Variables do
it 'does not return project variables' do it 'does not return project variables' do
get api("/projects/#{project.id}/variables") 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 end
end end
...@@ -42,7 +42,7 @@ describe API::Variables do ...@@ -42,7 +42,7 @@ describe API::Variables do
it 'returns project variable details' do it 'returns project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}", user) 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['value']).to eq(variable.value)
expect(json_response['protected']).to eq(variable.protected?) expect(json_response['protected']).to eq(variable.protected?)
expect(json_response['masked']).to eq(variable.masked?) expect(json_response['masked']).to eq(variable.masked?)
...@@ -52,7 +52,7 @@ describe API::Variables do ...@@ -52,7 +52,7 @@ describe API::Variables do
it 'responds with 404 Not Found if requesting non-existing variable' do it 'responds with 404 Not Found if requesting non-existing variable' do
get api("/projects/#{project.id}/variables/non_existing_variable", user) 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
end end
...@@ -60,7 +60,7 @@ describe API::Variables do ...@@ -60,7 +60,7 @@ describe API::Variables do
it 'does not return project variable details' do it 'does not return project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}", user2) 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
end end
...@@ -68,7 +68,7 @@ describe API::Variables do ...@@ -68,7 +68,7 @@ describe API::Variables do
it 'does not return project variable details' do it 'does not return project variable details' do
get api("/projects/#{project.id}/variables/#{variable.key}") 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 end
end end
...@@ -80,7 +80,7 @@ describe API::Variables do ...@@ -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 } 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) 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['key']).to eq('TEST_VARIABLE_2')
expect(json_response['value']).to eq('PROTECTED_VALUE_2') expect(json_response['value']).to eq('PROTECTED_VALUE_2')
expect(json_response['protected']).to be_truthy expect(json_response['protected']).to be_truthy
...@@ -93,7 +93,7 @@ describe API::Variables do ...@@ -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' } 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) 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['key']).to eq('TEST_VARIABLE_2')
expect(json_response['value']).to eq('VALUE_2') expect(json_response['value']).to eq('VALUE_2')
expect(json_response['protected']).to be_falsey expect(json_response['protected']).to be_falsey
...@@ -106,7 +106,7 @@ describe API::Variables do ...@@ -106,7 +106,7 @@ describe API::Variables do
post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' } post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
end.to change {project.variables.count}.by(0) 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 end
it 'creates variable with a specific environment scope' do it 'creates variable with a specific environment scope' do
...@@ -114,7 +114,7 @@ describe API::Variables 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/*' } 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) 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['key']).to eq('TEST_VARIABLE_2')
expect(json_response['value']).to eq('VALUE_2') expect(json_response['value']).to eq('VALUE_2')
expect(json_response['environment_scope']).to eq('review/*') expect(json_response['environment_scope']).to eq('review/*')
...@@ -127,7 +127,7 @@ describe API::Variables do ...@@ -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/*' } 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) 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['key']).to eq(variable.key)
expect(json_response['value']).to eq('VALUE_2') expect(json_response['value']).to eq('VALUE_2')
expect(json_response['environment_scope']).to eq('review/*') expect(json_response['environment_scope']).to eq('review/*')
...@@ -138,7 +138,7 @@ describe API::Variables do ...@@ -138,7 +138,7 @@ describe API::Variables do
it 'does not create variable' do it 'does not create variable' do
post api("/projects/#{project.id}/variables", user2) 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
end end
...@@ -146,7 +146,7 @@ describe API::Variables do ...@@ -146,7 +146,7 @@ describe API::Variables do
it 'does not create variable' do it 'does not create variable' do
post api("/projects/#{project.id}/variables") 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 end
end end
...@@ -161,7 +161,7 @@ describe API::Variables do ...@@ -161,7 +161,7 @@ describe API::Variables do
updated_variable = project.variables.reload.first 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(value_before).to eq(variable.value)
expect(updated_variable.value).to eq('VALUE_1_UP') expect(updated_variable.value).to eq('VALUE_1_UP')
expect(updated_variable).to be_protected expect(updated_variable).to be_protected
...@@ -171,7 +171,7 @@ describe API::Variables do ...@@ -171,7 +171,7 @@ describe API::Variables do
it 'responds with 404 Not Found if requesting non-existing variable' do it 'responds with 404 Not Found if requesting non-existing variable' do
put api("/projects/#{project.id}/variables/non_existing_variable", user) 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
end end
...@@ -179,7 +179,7 @@ describe API::Variables do ...@@ -179,7 +179,7 @@ describe API::Variables do
it 'does not update variable' do it 'does not update variable' do
put api("/projects/#{project.id}/variables/#{variable.key}", user2) 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
end end
...@@ -187,7 +187,7 @@ describe API::Variables do ...@@ -187,7 +187,7 @@ describe API::Variables do
it 'does not update variable' do it 'does not update variable' do
put api("/projects/#{project.id}/variables/#{variable.key}") 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 end
end end
...@@ -198,14 +198,14 @@ describe API::Variables do ...@@ -198,14 +198,14 @@ describe API::Variables do
expect do expect do
delete api("/projects/#{project.id}/variables/#{variable.key}", user) 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.to change {project.variables.count}.by(-1)
end end
it 'responds with 404 Not Found if requesting non-existing variable' do it 'responds with 404 Not Found if requesting non-existing variable' do
delete api("/projects/#{project.id}/variables/non_existing_variable", user) 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
end end
...@@ -213,7 +213,7 @@ describe API::Variables do ...@@ -213,7 +213,7 @@ describe API::Variables do
it 'does not delete variable' do it 'does not delete variable' do
delete api("/projects/#{project.id}/variables/#{variable.key}", user2) 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
end end
...@@ -221,7 +221,7 @@ describe API::Variables do ...@@ -221,7 +221,7 @@ describe API::Variables do
it 'does not delete variable' do it 'does not delete variable' do
delete api("/projects/#{project.id}/variables/#{variable.key}") 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 end
end end
......
...@@ -8,7 +8,7 @@ describe API::Version do ...@@ -8,7 +8,7 @@ describe API::Version do
it 'returns authentication error' do it 'returns authentication error' do
get api('/version') get api('/version')
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -51,13 +51,13 @@ describe API::Version do ...@@ -51,13 +51,13 @@ describe API::Version do
it 'returns authorization error' do it 'returns authorization error' do
get api('/version', personal_access_token: personal_access_token) 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 end
end end
def expect_version 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['version']).to eq(Gitlab::VERSION)
expect(json_response['revision']).to eq(Gitlab.revision) expect(json_response['revision']).to eq(Gitlab.revision)
end end
......
...@@ -32,7 +32,7 @@ describe API::Wikis do ...@@ -32,7 +32,7 @@ describe API::Wikis do
it 'returns the list of wiki pages without content' do it 'returns the list of wiki pages without content' do
get api(url, user) 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) expect(json_response.size).to eq(2)
json_response.each_with_index do |page, index| json_response.each_with_index do |page, index|
...@@ -45,7 +45,7 @@ describe API::Wikis do ...@@ -45,7 +45,7 @@ describe API::Wikis do
it 'returns the list of wiki pages with content' do it 'returns the list of wiki pages with content' do
get api(url, user), params: { with_content: 1 } 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) expect(json_response.size).to eq(2)
json_response.each_with_index do |page, index| json_response.each_with_index do |page, index|
...@@ -60,14 +60,14 @@ describe API::Wikis do ...@@ -60,14 +60,14 @@ describe API::Wikis do
it 'return the empty list of wiki pages' do it 'return the empty list of wiki pages' do
get api(url, user) 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) expect(json_response.size).to eq(0)
end end
end end
shared_examples_for 'returns wiki page' do shared_examples_for 'returns wiki page' do
it 'returns the 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.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(page.content) expect(json_response['content']).to eq(page.content)
...@@ -80,7 +80,7 @@ describe API::Wikis do ...@@ -80,7 +80,7 @@ describe API::Wikis do
it 'creates the wiki page' do it 'creates the wiki page' do
post(api(url, user), params: payload) 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.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(payload[:content]) expect(json_response['content']).to eq(payload[:content])
...@@ -95,7 +95,7 @@ describe API::Wikis do ...@@ -95,7 +95,7 @@ describe API::Wikis do
post(api(url, user), params: payload) 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.size).to eq(1)
expect(json_response['error']).to eq("#{part} is missing") expect(json_response['error']).to eq("#{part} is missing")
end end
...@@ -106,7 +106,7 @@ describe API::Wikis do ...@@ -106,7 +106,7 @@ describe API::Wikis do
it 'updates the wiki page' do it 'updates the wiki page' do
put(api(url, user), params: payload) 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.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content) expect(json_response.keys).to match_array(expected_keys_with_content)
expect(json_response['content']).to eq(payload[:content]) expect(json_response['content']).to eq(payload[:content])
...@@ -120,14 +120,14 @@ describe API::Wikis do ...@@ -120,14 +120,14 @@ describe API::Wikis do
put(api(url, user), params: payload) 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 end
end end
shared_examples_for '403 Forbidden' do shared_examples_for '403 Forbidden' do
it 'returns 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.size).to eq(1)
expect(json_response['message']).to eq('403 Forbidden') expect(json_response['message']).to eq('403 Forbidden')
end end
...@@ -135,7 +135,7 @@ describe API::Wikis do ...@@ -135,7 +135,7 @@ describe API::Wikis do
shared_examples_for '404 Wiki Page Not Found' do shared_examples_for '404 Wiki Page Not Found' do
it 'returns 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.size).to eq(1)
expect(json_response['message']).to eq('404 Wiki Page Not Found') expect(json_response['message']).to eq('404 Wiki Page Not Found')
end end
...@@ -143,7 +143,7 @@ describe API::Wikis do ...@@ -143,7 +143,7 @@ describe API::Wikis do
shared_examples_for '404 Project Not Found' do shared_examples_for '404 Project Not Found' do
it 'returns 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.size).to eq(1)
expect(json_response['message']).to eq('404 Project Not Found') expect(json_response['message']).to eq('404 Project Not Found')
end end
...@@ -151,7 +151,7 @@ describe API::Wikis do ...@@ -151,7 +151,7 @@ describe API::Wikis do
shared_examples_for '204 No Content' do shared_examples_for '204 No Content' do
it 'returns 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
end end
...@@ -161,7 +161,7 @@ describe API::Wikis do ...@@ -161,7 +161,7 @@ describe API::Wikis do
workhorse_post_with_file(api(url, user), file_key: :file, params: payload) 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 expect(json_response).to eq result_hash.deep_stringify_keys
end end
...@@ -170,7 +170,7 @@ describe API::Wikis do ...@@ -170,7 +170,7 @@ describe API::Wikis do
post(api(url, user), params: payload) 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.size).to eq(1)
expect(json_response['error']).to eq('file is missing') expect(json_response['error']).to eq('file is missing')
end end
...@@ -180,7 +180,7 @@ describe API::Wikis do ...@@ -180,7 +180,7 @@ describe API::Wikis do
post(api(url, user), params: payload) 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.size).to eq(1)
expect(json_response['error']).to eq('file is invalid') expect(json_response['error']).to eq('file is invalid')
end end
...@@ -190,7 +190,7 @@ describe API::Wikis do ...@@ -190,7 +190,7 @@ describe API::Wikis do
post(api(url, user), params: payload) 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 expect(json_response).to eq result_hash.deep_stringify_keys
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment