Commit 2ee5991b authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 6b1ba27e
...@@ -36,9 +36,16 @@ Personas are described at https://about.gitlab.com/handbook/marketing/product-ma ...@@ -36,9 +36,16 @@ Personas are described at https://about.gitlab.com/handbook/marketing/product-ma
Add all known Documentation Requirements here, per https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html#documentation-requirements Add all known Documentation Requirements here, per https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html#documentation-requirements
If this feature requires changing permissions, this document https://docs.gitlab.com/ee/user/permissions.html must be updated accordingly. --> If this feature requires changing permissions, this document https://docs.gitlab.com/ee/user/permissions.html must be updated accordingly. -->
### Testing ### Availability & Testing
<!-- What risks does this change pose? How might it affect the quality of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing? See the test engineering process for further help: https://about.gitlab.com/handbook/engineering/quality/test-engineering/ --> <!-- What risks does this change pose to our availability? How might it affect the quality of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing?
Please list the test areas (unit, integration and end-to-end) that needs to be added or updated to ensure that this feature will work as intended. Plese use the list below as guidance.
* Unit test changes
* Integration test changes
* End-to-end test change
See the test engineering planning process and reach out to your counterpart Software Engineer in Test for assistance : https://about.gitlab.com/handbook/engineering/quality/test-engineering/#test-planning -->
### What does success look like, and how can we measure that? ### What does success look like, and how can we measure that?
......
...@@ -301,24 +301,6 @@ RSpec/AnyInstanceOf: ...@@ -301,24 +301,6 @@ RSpec/AnyInstanceOf:
Enabled: false Enabled: false
# Cops for upgrade to gitlab-styles 3.1.0 # Cops for upgrade to gitlab-styles 3.1.0
Rails/SafeNavigationWithBlank:
Enabled: false
Rails/ApplicationController:
Enabled: false
Rails/ApplicationMailer:
Enabled: false
Rails/RakeEnvironment:
Enabled: false
Rails/HelperInstanceVariable:
Enabled: false
Rails/EnumHash:
Enabled: false
RSpec/ReceiveCounts: RSpec/ReceiveCounts:
Enabled: false Enabled: false
...@@ -362,10 +344,13 @@ RSpec/UnspecifiedException: ...@@ -362,10 +344,13 @@ RSpec/UnspecifiedException:
Enabled: false Enabled: false
RSpec/HaveGitlabHttpStatus: RSpec/HaveGitlabHttpStatus:
Enabled: false Enabled: true
Include:
- 'spec/support/shared_examples/**/*'
Style/MultilineWhenThen: Style/MultilineWhenThen:
Enabled: false Enabled: false
Style/FloatDivision: Style/FloatDivision:
Enabled: false Enabled: false
\ No newline at end of file
This diff is collapsed.
...@@ -8,6 +8,9 @@ export default { ...@@ -8,6 +8,9 @@ export default {
}, },
}, },
computed: { computed: {
displayAsCell() {
return !(this.line.rich_text || this.line.text);
},
lineType() { lineType() {
return this.line.type; return this.line.type;
}, },
...@@ -23,11 +26,9 @@ export default { ...@@ -23,11 +26,9 @@ export default {
<td class="diff-line-num new_line border-top-0 border-bottom-0" :class="lineType"> <td class="diff-line-num new_line border-top-0 border-bottom-0" :class="lineType">
{{ line.new_line }} {{ line.new_line }}
</td> </td>
<td class="line_content" :class="lineType"> <td class="line_content" :class="[{ 'd-table-cell': displayAsCell }, lineType]">
<span v-if="line.rich_text" v-html="line.rich_text"></span> <span v-if="line.rich_text" v-html="line.rich_text"></span>
<span v-else-if="line.text">{{ line.text }}</span> <span v-else-if="line.text">{{ line.text }}</span>
<!-- TODO: replace this hack with zero-width whitespace when we have rich_text from BE -->
<span v-else>&#8203;</span>
</td> </td>
</tr> </tr>
</template> </template>
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
.mh-50vh { max-height: 50vh; } .mh-50vh { max-height: 50vh; }
.gl-w-64 { width: px-to-rem($grid-size * 8); } .gl-w-64 { width: px-to-rem($grid-size * 8); }
.gl-h-32 { height: px-to-rem($grid-size * 4); }
.gl-h-64 { height: px-to-rem($grid-size * 8); } .gl-h-64 { height: px-to-rem($grid-size * 8); }
.gl-text-purple { color: $purple; } .gl-text-purple { color: $purple; }
...@@ -59,4 +60,3 @@ ...@@ -59,4 +60,3 @@
.gl-text-red-700 { @include gl-text-red-700; } .gl-text-red-700 { @include gl-text-red-700; }
.gl-text-orange-700 { @include gl-text-orange-700; } .gl-text-orange-700 { @include gl-text-orange-700; }
.gl-text-green-700 { @include gl-text-green-700; } .gl-text-green-700 { @include gl-text-green-700; }
...@@ -223,19 +223,19 @@ class User < ApplicationRecord ...@@ -223,19 +223,19 @@ class User < ApplicationRecord
after_initialize :set_projects_limit after_initialize :set_projects_limit
# User's Layout preference # User's Layout preference
enum layout: [:fixed, :fluid] enum layout: { fixed: 0, fluid: 1 }
# User's Dashboard preference # User's Dashboard preference
# Note: When adding an option, it MUST go on the end of the array. # Note: When adding an option, it MUST go on the end of the array.
enum dashboard: [:projects, :stars, :project_activity, :starred_project_activity, :groups, :todos, :issues, :merge_requests, :operations] enum dashboard: { projects: 0, stars: 1, project_activity: 2, starred_project_activity: 3, groups: 4, todos: 5, issues: 6, merge_requests: 7, operations: 8 }
# User's Project preference # User's Project preference
# Note: When adding an option, it MUST go on the end of the array. # Note: When adding an option, it MUST go on the end of the array.
enum project_view: [:readme, :activity, :files] enum project_view: { readme: 0, activity: 1, files: 2 }
# User's role # User's role
# Note: When adding an option, it MUST go on the end of the array. # Note: When adding an option, it MUST go on the end of the array.
enum role: [:software_developer, :development_team_lead, :devops_engineer, :systems_administrator, :security_analyst, :data_analyst, :product_manager, :product_designer, :other], _suffix: true enum role: { software_developer: 0, development_team_lead: 1, devops_engineer: 2, systems_administrator: 3, security_analyst: 4, data_analyst: 5, product_manager: 6, product_designer: 7, other: 8 }, _suffix: true
delegate :path, to: :namespace, allow_nil: true, prefix: true delegate :path, to: :namespace, allow_nil: true, prefix: true
delegate :notes_filter_for, to: :user_preference delegate :notes_filter_for, to: :user_preference
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
Enable version check Enable version check
.form-text.text-muted .form-text.text-muted
GitLab will inform you if a new version is available. GitLab will inform you if a new version is available.
= link_to 'Learn more', help_page_path("user/admin_area/settings/usage_statistics", anchor: "version-check") = link_to 'Learn more', help_page_path('user/admin_area/settings/usage_statistics', anchor: 'version-check-core-only')
about what information is shared with GitLab Inc. about what information is shared with GitLab Inc.
.form-group .form-group
- can_be_configured = @application_setting.usage_ping_can_be_configured? - can_be_configured = @application_setting.usage_ping_can_be_configured?
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- if can_be_configured - if can_be_configured
%p.mb-2= _('To help improve GitLab and its user experience, GitLab will periodically collect usage information.') %p.mb-2= _('To help improve GitLab and its user experience, GitLab will periodically collect usage information.')
- usage_ping_path = help_page_path('user/admin_area/settings/usage_statistics', anchor: 'usage-ping') - usage_ping_path = help_page_path('user/admin_area/settings/usage_statistics', anchor: 'usage-ping-core-only')
- usage_ping_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: usage_ping_path } - usage_ping_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: usage_ping_path }
%p.mb-2= s_('%{usage_ping_link_start}Learn more%{usage_ping_link_end} about what information is shared with GitLab Inc.').html_safe % { usage_ping_link_start: usage_ping_link_start, usage_ping_link_end: '</a>'.html_safe } %p.mb-2= s_('%{usage_ping_link_start}Learn more%{usage_ping_link_end} about what information is shared with GitLab Inc.').html_safe % { usage_ping_link_start: usage_ping_link_start, usage_ping_link_end: '</a>'.html_safe }
......
...@@ -6,27 +6,25 @@ ...@@ -6,27 +6,25 @@
- if can?(current_user, :admin_cluster, @cluster) - if can?(current_user, :admin_cluster, @cluster)
- unless @cluster.provided_by_user? - unless @cluster.provided_by_user?
.append-bottom-20 .sub-section.form-group
%label.append-bottom-10 %h4
= @cluster.provider_label = @cluster.provider_label
%p %p
- provider_link = link_to(@cluster.provider_label, @cluster.provider_management_url, target: '_blank', rel: 'noopener noreferrer') - provider_link = link_to(@cluster.provider_label, @cluster.provider_management_url, target: '_blank', rel: 'noopener noreferrer')
= s_('ClusterIntegration|Manage your Kubernetes cluster by visiting %{provider_link}').html_safe % { provider_link: provider_link } = s_('ClusterIntegration|Manage your Kubernetes cluster by visiting %{provider_link}').html_safe % { provider_link: provider_link }
= form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster, html: { class: 'cluster_management_form' } do |field| .sub-section.form-group
= form_for @cluster, url: clusterable.cluster_path(@cluster), as: :cluster, html: { class: 'cluster_management_form' } do |field|
%h5 %h4
= s_('ClusterIntegration|Cluster management project (alpha)') = s_('ClusterIntegration|Cluster management project (alpha)')
.form-group %p
.form-text.text-muted = project_select_tag('cluster[management_project_id]', class: 'hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit',
= project_select_tag('cluster[management_project_id]', class: 'hidden-filter-value', toggle_class: 'js-project-search js-project-filter js-filter-submit', dropdown_class: 'dropdown-menu-selectable dropdown-menu-project js-filter-submit', placeholder: _('Select project'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', simple_filter: true, allow_clear: true, include_groups: false, include_projects_in_subgroups: true, group_id: group_id, user_id: user_id }, value: @cluster.management_project_id)
placeholder: _('Select project'), idAttribute: 'id', data: { order_by: 'last_activity_at', idattribute: 'id', simple_filter: true, allow_clear: true, include_groups: false, include_projects_in_subgroups: true, group_id: group_id, user_id: user_id }, value: @cluster.management_project_id) .text-muted
.text-muted = s_('ClusterIntegration|A cluster management project can be used to run deployment jobs with Kubernetes <code>cluster-admin</code> privileges.').html_safe
= s_('ClusterIntegration|A cluster management project can be used to run deployment jobs with Kubernetes <code>cluster-admin</code> privileges.').html_safe = link_to _('More information'), help_page_path('user/clusters/management_project.md'), target: '_blank'
= link_to _('More information'), help_page_path('user/clusters/management_project.md'), target: '_blank' = field.submit _('Save changes'), class: 'btn btn-success'
.form-group
= field.submit _('Save changes'), class: 'btn btn-success qa-save-domain'
- if @cluster.managed? - if @cluster.managed?
.sub-section.form-group .sub-section.form-group
......
...@@ -9,6 +9,6 @@ ...@@ -9,6 +9,6 @@
- usage_ping_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: usage_ping_path } - usage_ping_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: usage_ping_path }
= s_('User Cohorts are only shown when the %{usage_ping_link_start}usage ping%{usage_ping_link_end} is enabled.').html_safe % { usage_ping_link_start: usage_ping_link_start, usage_ping_link_end: '</a>'.html_safe } = s_('User Cohorts are only shown when the %{usage_ping_link_start}usage ping%{usage_ping_link_end} is enabled.').html_safe % { usage_ping_link_start: usage_ping_link_start, usage_ping_link_end: '</a>'.html_safe }
- if current_user.admin? - if current_user.admin?
- application_settings_path = admin_application_settings_path(anchor: 'usage-statistics') - application_settings_path = metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings')
- application_settings_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: application_settings_path } - application_settings_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: application_settings_path }
= s_('To enable it and see User Cohorts, visit %{application_settings_link_start}application settings%{application_settings_link_end}.').html_safe % { application_settings_link_start: application_settings_link_start, application_settings_link_end: '</a>'.html_safe } = s_('To enable it and see User Cohorts, visit %{application_settings_link_start}application settings%{application_settings_link_end}.').html_safe % { application_settings_link_start: application_settings_link_start, application_settings_link_end: '</a>'.html_safe }
- if session[:ask_for_usage_stats_consent] - if session[:ask_for_usage_stats_consent]
.ping-consent-message.alert.alert-warning.flex-alert .ping-consent-message.alert.alert-warning.flex-alert
- settings_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="alert-link">'.html_safe % { url: admin_application_settings_path(anchor: 'js-usage-settings') } - settings_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="alert-link">'.html_safe % { url: metrics_and_profiling_admin_application_settings_path(anchor: 'js-usage-settings') }
- info_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="alert-link">'.html_safe % { url: help_page_path('user/admin_area/settings/usage_statistics.md') } - info_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer" class="alert-link">'.html_safe % { url: help_page_path('user/admin_area/settings/usage_statistics.md') }
.alert-message .alert-message
= s_('To help improve GitLab, we would like to periodically collect usage information. This can be changed at any time in %{settings_link_start}Settings%{link_end}. %{info_link_start}More Information%{link_end}').html_safe % { settings_link_start: settings_link_start, info_link_start: info_link_start, link_end: '</a>'.html_safe } = s_('To help improve GitLab, we would like to periodically collect usage information. This can be changed at any time in %{settings_link_start}Settings%{link_end}. %{info_link_start}More Information%{link_end}').html_safe % { settings_link_start: settings_link_start, info_link_start: info_link_start, link_end: '</a>'.html_safe }
......
---
title: Fix loading of sub-epics caused by wrong subscription check.
merge_request: 23184
author:
type: fixed
---
title: Use consistent layout in cluster advanced settings
merge_request: 22656
author:
type: other
---
title: Allow SSH keys API endpoint to be requested for a given username
merge_request: 22899
author: Rajendra Kadam
type: changed
...@@ -677,12 +677,12 @@ Parameters: ...@@ -677,12 +677,12 @@ Parameters:
Get a list of a specified user's SSH keys. Get a list of a specified user's SSH keys.
``` ```
GET /users/:id/keys GET /users/:id_or_username/keys
``` ```
Parameters: | Attribute | Type | Required | Description |
| ---------------- | ------ | -------- | ----------- |
- `id` (required) - id of specified user | `id_or_username` | string | yes | The id or username of the user to get the SSH keys for. |
## Single SSH key ## Single SSH key
......
...@@ -85,6 +85,35 @@ subgraph "gitlab-qa pipeline" ...@@ -85,6 +85,35 @@ subgraph "gitlab-qa pipeline"
1. The result of the GitLab QA pipeline is being 1. The result of the GitLab QA pipeline is being
propagated upstream, through Omnibus, back to the CE / EE merge request. propagated upstream, through Omnibus, back to the CE / EE merge request.
Please note, we plan to [add more specific information](https://gitlab.com/gitlab-org/quality/team-tasks/issues/156)
about the tests included in each job/scenario that runs in `gitlab-qa`.
##### Running custom tests
The [existing scenarios](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md)
that run in the downstream `gitlab-qa` pipeline include many tests, but there are times when you might want to run a
test or a group of tests that are different than the groups in any of the existing scenarios.
For example, when we [dequarantine](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#dequarantining-tests)
a flaky test we first want to make sure that it's no longer flaky.
We can do that using the `ce:custom-parallel` and `ee:custom-parallel` jobs.
Both are manual jobs that you can configure using custom variables.
When you click the name (not the play icon) of one of the parallel jobs,
you'll be prompted to enter variables. You can use any of [the variables
that can be used with `gitlab-qa`](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#supported-gitlab-environment-variables)
as well as these:
| Variable | Description |
|-|-|
| `QA_SCENARIO` | The scenario to run (default `Test::Instance::Image`) |
| `QA_TESTS` | The test(s) to run (no default, which means run all the tests in the scenario). Use file paths as you would when running tests via RSpec, e.g., `qa/specs/features/ee/browser_ui` would include all the `EE` UI tests. |
| `QA_RSPEC_TAGS` | The RSpec tags to add (no default) |
For now [manual jobs with custom variables will not use the same variable
when retried](https://gitlab.com/gitlab-org/gitlab/issues/31367), so if you want to run the same test(s) multiple times,
specify the same variables in each `custom-parallel` job (up to as
many of the 10 available jobs that you want to run).
#### Using the `review-qa-all` jobs #### Using the `review-qa-all` jobs
On every pipeline during the `test` stage, the `review-qa-smoke` job is On every pipeline during the `test` stage, the `review-qa-smoke` job is
...@@ -105,8 +134,9 @@ See [Review Apps][review-apps] for more details about Review Apps. ...@@ -105,8 +134,9 @@ See [Review Apps][review-apps] for more details about Review Apps.
## How do I run the tests? ## How do I run the tests?
There are two main options for running the tests. If you simply want to run the If you are not [testing code in a merge request](#testing-code-in-merge-requests),
existing tests against a live GitLab instance or against a pre-built docker image there are two main options for running the tests. If you simply want to run
the existing tests against a live GitLab instance or against a pre-built docker image
you can use the [GitLab QA orchestrator][gitlab-qa-readme]. See also [examples you can use the [GitLab QA orchestrator][gitlab-qa-readme]. See also [examples
of the test scenarios you can run via the orchestrator](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#examples). of the test scenarios you can run via the orchestrator](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#examples).
......
...@@ -252,17 +252,15 @@ module API ...@@ -252,17 +252,15 @@ module API
success Entities::SSHKey success Entities::SSHKey
end end
params do params do
requires :id, type: Integer, desc: 'The ID of the user' requires :user_id, type: String, desc: 'The ID or username of the user'
use :pagination use :pagination
end end
# rubocop: disable CodeReuse/ActiveRecord get ':user_id/keys', requirements: API::USER_REQUIREMENTS do
get ':id/keys' do user = find_user(params[:user_id])
user = User.find_by(id: params[:id])
not_found!('User') unless user && can?(current_user, :read_user, user) not_found!('User') unless user && can?(current_user, :read_user, user)
present paginate(user.keys), with: Entities::SSHKey present paginate(user.keys), with: Entities::SSHKey
end end
# rubocop: enable CodeReuse/ActiveRecord
desc 'Delete an existing SSH key from a specified user. Available only for admins.' do desc 'Delete an existing SSH key from a specified user. Available only for admins.' do
success Entities::SSHKey success Entities::SSHKey
......
...@@ -638,6 +638,12 @@ msgstr "" ...@@ -638,6 +638,12 @@ msgstr ""
msgid "1st contribution!" msgid "1st contribution!"
msgstr "" msgstr ""
msgid "2 days"
msgstr ""
msgid "2 weeks"
msgstr ""
msgid "20-29 contributions" msgid "20-29 contributions"
msgstr "" msgstr ""
...@@ -665,6 +671,9 @@ msgstr "" ...@@ -665,6 +671,9 @@ msgstr ""
msgid "30+ contributions" msgid "30+ contributions"
msgstr "" msgstr ""
msgid "4 hours"
msgstr ""
msgid "403|Please contact your GitLab administrator to get permission." msgid "403|Please contact your GitLab administrator to get permission."
msgstr "" msgstr ""
...@@ -7183,6 +7192,9 @@ msgstr "" ...@@ -7183,6 +7192,9 @@ msgstr ""
msgid "Environments|Show all" msgid "Environments|Show all"
msgstr "" msgstr ""
msgid "Environments|Show last"
msgstr ""
msgid "Environments|Stop" msgid "Environments|Stop"
msgstr "" msgstr ""
...@@ -13082,6 +13094,9 @@ msgstr "" ...@@ -13082,6 +13094,9 @@ msgstr ""
msgid "Past due" msgid "Past due"
msgstr "" msgstr ""
msgid "Past week"
msgstr ""
msgid "Paste a machine public key here. Read more about how to generate it %{link_start}here%{link_end}" msgid "Paste a machine public key here. Read more about how to generate it %{link_start}here%{link_end}"
msgstr "" msgstr ""
...@@ -21776,6 +21791,9 @@ msgstr "" ...@@ -21776,6 +21791,9 @@ msgstr ""
msgid "ciReport|%{linkStartTag}Learn more about SAST %{linkEndTag}" msgid "ciReport|%{linkStartTag}Learn more about SAST %{linkEndTag}"
msgstr "" msgstr ""
msgid "ciReport|%{linkStartTag}Learn more about codequality reports %{linkEndTag}"
msgstr ""
msgid "ciReport|%{namespace} is affected by %{vulnerability}." msgid "ciReport|%{namespace} is affected by %{vulnerability}."
msgstr "" msgstr ""
...@@ -21864,6 +21882,9 @@ msgstr "" ...@@ -21864,6 +21882,9 @@ msgstr ""
msgid "ciReport|Automatically apply the patch in a new branch" msgid "ciReport|Automatically apply the patch in a new branch"
msgstr "" msgstr ""
msgid "ciReport|Base pipeline codequality artifact not found"
msgstr ""
msgid "ciReport|Class" msgid "ciReport|Class"
msgstr "" msgstr ""
......
...@@ -124,9 +124,6 @@ describe('Dashboard', () => { ...@@ -124,9 +124,6 @@ describe('Dashboard', () => {
.then(() => { .then(() => {
expect(wrapper.vm.showEmptyState).toEqual(false); expect(wrapper.vm.showEmptyState).toEqual(false);
expect(wrapper.vm.$el.querySelector('.prometheus-panel')).toEqual(null); expect(wrapper.vm.$el.querySelector('.prometheus-panel')).toEqual(null);
// TODO: The last expectation doesn't belong here, it belongs in a `group_group_spec.js` file
// Issue: https://gitlab.com/gitlab-org/gitlab/issues/118780
// expect(wrapper.vm.$el.querySelector('.prometheus-graph-group')).toBeTruthy();
done(); done();
}) })
......
...@@ -63,21 +63,59 @@ describe('SuggestionDiffRow', () => { ...@@ -63,21 +63,59 @@ describe('SuggestionDiffRow', () => {
it('renders the plain text when it is available but rich text is not', () => { it('renders the plain text when it is available but rich text is not', () => {
factory({ factory({
propsData: { propsData: {
line: Object.assign({}, newLine, { rich_text: undefined }), line: {
...newLine,
rich_text: undefined,
},
}, },
}); });
expect(wrapper.find('td.line_content').text()).toEqual('newplaintext'); expect(wrapper.find('td.line_content').text()).toEqual('newplaintext');
}); });
it('renders a zero-width space when it has no plain or rich texts', () => { it('switches to table-cell display when it has no plain or rich texts', () => {
factory({ factory({
propsData: { propsData: {
line: Object.assign({}, newLine, { rich_text: undefined, text: undefined }), line: {
...newLine,
text: undefined,
rich_text: undefined,
},
}, },
}); });
expect(wrapper.find('td.line_content').text()).toEqual('\u200B'); const lineContent = wrapper.find('td.line_content');
expect(lineContent.classes()).toContain('d-table-cell');
expect(lineContent.text()).toEqual('');
});
it('does not switch to table-cell display if it has either plain or rich texts', () => {
let lineContent;
factory({
propsData: {
line: {
...newLine,
text: undefined,
},
},
});
lineContent = wrapper.find('td.line_content');
expect(lineContent.classes()).not.toContain('d-table-cell');
factory({
propsData: {
line: {
...newLine,
rich_text: undefined,
},
},
});
lineContent = wrapper.find('td.line_content');
expect(lineContent.classes()).not.toContain('d-table-cell');
}); });
}); });
......
...@@ -913,6 +913,27 @@ describe API::Users do ...@@ -913,6 +913,27 @@ describe API::Users do
end end
end end
describe 'GET /user/:user_id/keys' do
it 'returns 404 for non-existing user' do
get api("/users/#{not_existing_user_id}/keys")
expect(response).to have_gitlab_http_status(404)
expect(json_response['message']).to eq('404 User Not Found')
end
it 'returns array of ssh keys' do
user.keys << key
user.save
get api("/users/#{user.username}/keys")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(key.title)
end
end
describe 'DELETE /user/:id/keys/:key_id' do describe 'DELETE /user/:id/keys/:key_id' do
before do before do
admin admin
......
...@@ -16,7 +16,7 @@ shared_examples 'disabled when using an external authorization service' do ...@@ -16,7 +16,7 @@ shared_examples 'disabled when using an external authorization service' do
subject subject
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -37,6 +37,6 @@ shared_examples 'unauthorized when external service denies access' do ...@@ -37,6 +37,6 @@ shared_examples 'unauthorized when external service denies access' do
subject subject
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -11,7 +11,7 @@ shared_examples 'paginated collection' do ...@@ -11,7 +11,7 @@ shared_examples 'paginated collection' do
it 'renders a page number that is not ouf of range' do it 'renders a page number that is not ouf of range' do
get action, params: params.merge(page: last_page) get action, params: params.merge(page: last_page)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'redirects to last_page if page number is larger than number of pages' do it 'redirects to last_page if page number is larger than number of pages' do
......
...@@ -51,7 +51,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| ...@@ -51,7 +51,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}|
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
context 'and lfs uses object storage' do context 'and lfs uses object storage' do
...@@ -65,7 +65,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| ...@@ -65,7 +65,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}|
it 'responds with redirect to file' do it 'responds with redirect to file' do
subject subject
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
expect(response.location).to include(lfs_object.reload.file.path) expect(response.location).to include(lfs_object.reload.file.path)
end end
...@@ -84,7 +84,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| ...@@ -84,7 +84,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}|
it 'does not serve the file' do it 'does not serve the file' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -97,7 +97,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| ...@@ -97,7 +97,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}|
it 'does not serve the file if no members are linked to the LfsObject' do it 'does not serve the file if no members are linked to the LfsObject' do
subject subject
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'serves the file when the fork network root is linked to the LfsObject' do it 'serves the file when the fork network root is linked to the LfsObject' do
...@@ -105,7 +105,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| ...@@ -105,7 +105,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}|
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'serves the file when the fork network member is linked to the LfsObject' do it 'serves the file when the fork network member is linked to the LfsObject' do
...@@ -113,7 +113,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| ...@@ -113,7 +113,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}|
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -154,7 +154,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}| ...@@ -154,7 +154,7 @@ shared_examples 'a controller that can serve LFS files' do |options = {}|
subject subject
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8') expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
expect(response.header['Content-Disposition']) expect(response.header['Content-Disposition'])
.to eq('inline') .to eq('inline')
......
...@@ -12,13 +12,13 @@ shared_examples 'todos actions' do ...@@ -12,13 +12,13 @@ shared_examples 'todos actions' do
post_create post_create
end.to change { user.todos.count }.by(1) end.to change { user.todos.count }.by(1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'returns todo path and pending count' do it 'returns todo path and pending count' do
post_create post_create
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['count']).to eq 1 expect(json_response['count']).to eq 1
expect(json_response['delete_path']).to match(%r{/dashboard/todos/\d{1}}) expect(json_response['delete_path']).to match(%r{/dashboard/todos/\d{1}})
end end
...@@ -31,7 +31,7 @@ shared_examples 'todos actions' do ...@@ -31,7 +31,7 @@ shared_examples 'todos actions' do
post_create post_create
end.to change { user.todos.count }.by(0) end.to change { user.todos.count }.by(0)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'does not create todo when user is not logged in' do it 'does not create todo when user is not logged in' do
...@@ -39,7 +39,7 @@ shared_examples 'todos actions' do ...@@ -39,7 +39,7 @@ shared_examples 'todos actions' do
post_create post_create
end.to change { user.todos.count }.by(0) end.to change { user.todos.count }.by(0)
expect(response).to have_gitlab_http_status(302) expect(response).to have_gitlab_http_status(:found)
end end
end end
end end
...@@ -27,7 +27,7 @@ shared_examples 'handle uploads' do ...@@ -27,7 +27,7 @@ shared_examples 'handle uploads' do
it "returns an error" do it "returns an error" do
post :create, params: params, format: :json post :create, params: params, format: :json
expect(response).to have_gitlab_http_status(422) expect(response).to have_gitlab_http_status(:unprocessable_entity)
end end
end end
...@@ -84,7 +84,7 @@ shared_examples 'handle uploads' do ...@@ -84,7 +84,7 @@ shared_examples 'handle uploads' do
show_upload show_upload
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -110,7 +110,7 @@ shared_examples 'handle uploads' do ...@@ -110,7 +110,7 @@ shared_examples 'handle uploads' do
it "responds with status 200" do it "responds with status 200" do
show_upload show_upload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -123,7 +123,7 @@ shared_examples 'handle uploads' do ...@@ -123,7 +123,7 @@ shared_examples 'handle uploads' do
it "responds with status 404" do it "responds with status 404" do
show_upload show_upload
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -135,7 +135,7 @@ shared_examples 'handle uploads' do ...@@ -135,7 +135,7 @@ shared_examples 'handle uploads' do
it "responds with status 404" do it "responds with status 404" do
show_upload show_upload
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -149,7 +149,7 @@ shared_examples 'handle uploads' do ...@@ -149,7 +149,7 @@ shared_examples 'handle uploads' do
it "responds with status 200" do it "responds with status 200" do
show_upload show_upload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -161,7 +161,7 @@ shared_examples 'handle uploads' do ...@@ -161,7 +161,7 @@ shared_examples 'handle uploads' do
it "responds with status 404" do it "responds with status 404" do
show_upload show_upload
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -182,7 +182,7 @@ shared_examples 'handle uploads' do ...@@ -182,7 +182,7 @@ shared_examples 'handle uploads' do
it "responds with status 200" do it "responds with status 200" do
show_upload show_upload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -226,7 +226,7 @@ shared_examples 'handle uploads' do ...@@ -226,7 +226,7 @@ shared_examples 'handle uploads' do
it "responds with status 200" do it "responds with status 200" do
show_upload show_upload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -238,7 +238,7 @@ shared_examples 'handle uploads' do ...@@ -238,7 +238,7 @@ shared_examples 'handle uploads' do
it "responds with status 404" do it "responds with status 404" do
show_upload show_upload
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -253,7 +253,7 @@ shared_examples 'handle uploads' do ...@@ -253,7 +253,7 @@ shared_examples 'handle uploads' do
it "responds with status 200" do it "responds with status 200" do
show_upload show_upload
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -265,7 +265,7 @@ shared_examples 'handle uploads' do ...@@ -265,7 +265,7 @@ shared_examples 'handle uploads' do
it "responds with status 404" do it "responds with status 404" do
show_upload show_upload
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -278,7 +278,7 @@ shared_examples 'handle uploads' do ...@@ -278,7 +278,7 @@ shared_examples 'handle uploads' do
it "responds with status 404" do it "responds with status 404" do
show_upload show_upload
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -321,7 +321,7 @@ shared_examples 'handle uploads authorize' do ...@@ -321,7 +321,7 @@ shared_examples 'handle uploads authorize' do
end end
it 'responds with status 200' do it 'responds with status 200' do
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
it 'uses the gitlab-workhorse content type' do it 'uses the gitlab-workhorse content type' do
......
...@@ -6,7 +6,7 @@ shared_examples 'discussions provider' do ...@@ -6,7 +6,7 @@ shared_examples 'discussions provider' do
it 'returns the expected discussions' do it 'returns the expected discussions' do
get :discussions, params: { namespace_id: project.namespace, project_id: project, id: requested_iid } get :discussions, params: { namespace_id: project.namespace, project_id: project, id: requested_iid }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('entities/discussions') expect(response).to match_response_schema('entities/discussions')
expect(json_response.size).to eq(expected_discussion_count) expect(json_response.size).to eq(expected_discussion_count)
......
...@@ -13,7 +13,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -13,7 +13,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it 'does not filter by custom attributes' do it 'does not filter by custom attributes' do
get api("/#{attributable_name}", user), params: { custom_attributes: { foo: 'foo', bar: 'bar' } } get api("/#{attributable_name}", user), params: { custom_attributes: { foo: 'foo', bar: 'bar' } }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to be 2 expect(json_response.size).to be 2
expect(json_response.map { |r| r['id'] }).to contain_exactly attributable.id, other_attributable.id expect(json_response.map { |r| r['id'] }).to contain_exactly attributable.id, other_attributable.id
end end
...@@ -23,7 +23,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -23,7 +23,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it 'filters by custom attributes' do it 'filters by custom attributes' do
get api("/#{attributable_name}", admin), params: { custom_attributes: { foo: 'foo', bar: 'bar' } } get api("/#{attributable_name}", admin), params: { custom_attributes: { foo: 'foo', bar: 'bar' } }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to be 1 expect(json_response.size).to be 1
expect(json_response.first['id']).to eq attributable.id expect(json_response.first['id']).to eq attributable.id
end end
...@@ -39,7 +39,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -39,7 +39,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it 'does not include custom attributes' do it 'does not include custom attributes' do
get api("/#{attributable_name}", user), params: { with_custom_attributes: true } get api("/#{attributable_name}", user), params: { with_custom_attributes: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to be 2 expect(json_response.size).to be 2
expect(json_response.first).not_to include 'custom_attributes' expect(json_response.first).not_to include 'custom_attributes'
end end
...@@ -49,7 +49,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -49,7 +49,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it 'does not include custom attributes by default' do it 'does not include custom attributes by default' do
get api("/#{attributable_name}", admin) get api("/#{attributable_name}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to be 2 expect(json_response.size).to be 2
expect(json_response.first).not_to include 'custom_attributes' expect(json_response.first).not_to include 'custom_attributes'
expect(json_response.second).not_to include 'custom_attributes' expect(json_response.second).not_to include 'custom_attributes'
...@@ -58,7 +58,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -58,7 +58,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it 'includes custom attributes if requested' do it 'includes custom attributes if requested' do
get api("/#{attributable_name}", admin), params: { with_custom_attributes: true } get api("/#{attributable_name}", admin), params: { with_custom_attributes: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to be 2 expect(json_response.size).to be 2
attributable_response = json_response.find { |r| r['id'] == attributable.id } attributable_response = json_response.find { |r| r['id'] == attributable.id }
...@@ -79,7 +79,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -79,7 +79,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it 'does not include custom attributes' do it 'does not include custom attributes' do
get api("/#{attributable_name}/#{attributable.id}", user), params: { with_custom_attributes: true } get api("/#{attributable_name}/#{attributable.id}", user), params: { with_custom_attributes: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include 'custom_attributes' expect(json_response).not_to include 'custom_attributes'
end end
end end
...@@ -88,14 +88,14 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -88,14 +88,14 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it 'does not include custom attributes by default' do it 'does not include custom attributes by default' do
get api("/#{attributable_name}/#{attributable.id}", admin) get api("/#{attributable_name}/#{attributable.id}", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to include 'custom_attributes' expect(json_response).not_to include 'custom_attributes'
end end
it 'includes custom attributes if requested' do it 'includes custom attributes if requested' do
get api("/#{attributable_name}/#{attributable.id}", admin), params: { with_custom_attributes: true } get api("/#{attributable_name}/#{attributable.id}", admin), params: { with_custom_attributes: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['custom_attributes']).to contain_exactly( expect(json_response['custom_attributes']).to contain_exactly(
{ 'key' => 'foo', 'value' => 'foo' }, { 'key' => 'foo', 'value' => 'foo' },
{ 'key' => 'bar', 'value' => 'bar' } { 'key' => 'bar', 'value' => 'bar' }
...@@ -115,7 +115,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -115,7 +115,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it 'returns all custom attributes' do it 'returns all custom attributes' do
get api("/#{attributable_name}/#{attributable.id}/custom_attributes", admin) get api("/#{attributable_name}/#{attributable.id}/custom_attributes", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to contain_exactly( expect(json_response).to contain_exactly(
{ 'key' => 'foo', 'value' => 'foo' }, { 'key' => 'foo', 'value' => 'foo' },
{ 'key' => 'bar', 'value' => 'bar' } { 'key' => 'bar', 'value' => 'bar' }
...@@ -135,7 +135,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -135,7 +135,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
it'returns a single custom attribute' do it'returns a single custom attribute' do
get api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin) get api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'key' => 'foo', 'value' => 'foo' }) expect(json_response).to eq({ 'key' => 'foo', 'value' => 'foo' })
end end
end end
...@@ -154,7 +154,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -154,7 +154,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
put api("/#{attributable_name}/#{attributable.id}/custom_attributes/new", admin), params: { value: 'new' } put api("/#{attributable_name}/#{attributable.id}/custom_attributes/new", admin), params: { value: 'new' }
end.to change { attributable.custom_attributes.count }.by(1) end.to change { attributable.custom_attributes.count }.by(1)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'key' => 'new', 'value' => 'new' }) expect(json_response).to eq({ 'key' => 'new', 'value' => 'new' })
expect(attributable.custom_attributes.find_by(key: 'new').value).to eq 'new' expect(attributable.custom_attributes.find_by(key: 'new').value).to eq 'new'
end end
...@@ -164,7 +164,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -164,7 +164,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin), params: { value: 'new' } put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin), params: { value: 'new' }
end.not_to change { attributable.custom_attributes.count } end.not_to change { attributable.custom_attributes.count }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq({ 'key' => 'foo', 'value' => 'new' }) expect(json_response).to eq({ 'key' => 'foo', 'value' => 'new' })
expect(custom_attribute1.reload.value).to eq 'new' expect(custom_attribute1.reload.value).to eq 'new'
end end
...@@ -184,7 +184,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name| ...@@ -184,7 +184,7 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
delete api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin) delete api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin)
end.to change { attributable.custom_attributes.count }.by(-1) end.to change { attributable.custom_attributes.count }.by(-1)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
expect(attributable.custom_attributes.find_by(key: 'foo')).to be_nil expect(attributable.custom_attributes.find_by(key: 'foo')).to be_nil
end end
end end
......
...@@ -7,7 +7,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| ...@@ -7,7 +7,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
discussion = json_response.find { |record| record['id'] == diff_note.discussion_id } discussion = json_response.find { |record| record['id'] == diff_note.discussion_id }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(discussion).not_to be_nil expect(discussion).not_to be_nil
expect(discussion['individual_note']).to eq(false) expect(discussion['individual_note']).to eq(false)
expect(discussion['notes'].first['body']).to eq(diff_note.note) expect(discussion['notes'].first['body']).to eq(diff_note.note)
...@@ -18,7 +18,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| ...@@ -18,7 +18,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
it "returns a discussion by id" do it "returns a discussion by id" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/#{diff_note.discussion_id}", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/#{diff_note.discussion_id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(diff_note.discussion_id) expect(json_response['id']).to eq(diff_note.discussion_id)
expect(json_response['notes'].first['body']).to eq(diff_note.note) expect(json_response['notes'].first['body']).to eq(diff_note.note)
expect(json_response['notes'].first['position']).to eq(diff_note.position.to_h.stringify_keys) expect(json_response['notes'].first['position']).to eq(diff_note.position.to_h.stringify_keys)
...@@ -32,7 +32,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| ...@@ -32,7 +32,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
params: { body: 'hi!', position: position } params: { body: 'hi!', position: position }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['notes'].first['body']).to eq('hi!') expect(json_response['notes'].first['body']).to eq('hi!')
expect(json_response['notes'].first['type']).to eq('DiffNote') expect(json_response['notes'].first['type']).to eq('DiffNote')
expect(json_response['notes'].first['position']).to eq(position.stringify_keys) expect(json_response['notes'].first['position']).to eq(position.stringify_keys)
...@@ -45,7 +45,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| ...@@ -45,7 +45,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
params: { body: 'hi!', position: position } params: { body: 'hi!', position: position }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 400 bad request error when the position is not valid for this discussion" do it "returns a 400 bad request error when the position is not valid for this discussion" do
...@@ -54,7 +54,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| ...@@ -54,7 +54,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
params: { body: 'hi!', position: position } params: { body: 'hi!', position: position }
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -64,7 +64,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name| ...@@ -64,7 +64,7 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{diff_note.discussion_id}/notes", user), params: { body: 'hi!' } "discussions/#{diff_note.discussion_id}/notes", user), params: { body: 'hi!' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('hi!') expect(json_response['body']).to eq('hi!')
expect(json_response['type']).to eq('DiffNote') expect(json_response['type']).to eq('DiffNote')
end end
......
...@@ -23,7 +23,7 @@ shared_examples 'with cross-reference system notes' do ...@@ -23,7 +23,7 @@ shared_examples 'with cross-reference system notes' do
it 'returns only the note that the user should see' do it 'returns only the note that the user should see' do
get api(url, user, personal_access_token: pat) get api(url, user, personal_access_token: pat)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response.count).to eq(1) expect(json_response.count).to eq(1)
expect(notes_in_response.count).to eq(1) expect(notes_in_response.count).to eq(1)
...@@ -40,7 +40,7 @@ shared_examples 'with cross-reference system notes' do ...@@ -40,7 +40,7 @@ shared_examples 'with cross-reference system notes' do
get api(url, user, personal_access_token: pat) get api(url, user, personal_access_token: pat)
end end
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
RequestStore.clear! RequestStore.clear!
...@@ -50,7 +50,7 @@ shared_examples 'with cross-reference system notes' do ...@@ -50,7 +50,7 @@ shared_examples 'with cross-reference system notes' do
RequestStore.clear! RequestStore.clear!
expect { get api(url, user, personal_access_token: pat) }.not_to exceed_query_limit(control) expect { get api(url, user, personal_access_token: pat) }.not_to exceed_query_limit(control)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -59,7 +59,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -59,7 +59,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
it "returns an array of discussions" do it "returns an array of discussions" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['id']).to eq(note.discussion_id) expect(json_response.first['id']).to eq(note.discussion_id)
...@@ -68,7 +68,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -68,7 +68,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
it "returns a 404 error when noteable id not found" do it "returns a 404 error when noteable id not found" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/12345/discussions", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/12345/discussions", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns 404 when not authorized" do it "returns 404 when not authorized" do
...@@ -76,7 +76,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -76,7 +76,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", private_user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", private_user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -84,7 +84,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -84,7 +84,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
it "returns a discussion by id" do it "returns a discussion by id" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/#{note.discussion_id}", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/#{note.discussion_id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(note.discussion_id) expect(json_response['id']).to eq(note.discussion_id)
expect(json_response['notes'].first['body']).to eq(note.note) expect(json_response['notes'].first['body']).to eq(note.note)
end end
...@@ -92,7 +92,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -92,7 +92,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
it "returns a 404 error if discussion not found" do it "returns a 404 error if discussion not found" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/12345", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/12345", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -100,7 +100,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -100,7 +100,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
it "creates a new note" do it "creates a new note" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!' } post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['notes'].first['body']).to eq('hi!') expect(json_response['notes'].first['body']).to eq('hi!')
expect(json_response['notes'].first['author']['username']).to eq(user.username) expect(json_response['notes'].first['author']['username']).to eq(user.username)
end end
...@@ -108,13 +108,13 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -108,13 +108,13 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
it "returns a 400 bad request error if body not given" do it "returns a 400 bad request error if body not given" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user) post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 401 unauthorized error if user not authenticated" do it "returns a 401 unauthorized error if user not authenticated" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions"), params: { body: 'hi!' } post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions"), params: { body: 'hi!' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it 'tracks a Notes::CreateService event' do it 'tracks a Notes::CreateService event' do
...@@ -146,7 +146,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -146,7 +146,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
params: { body: 'hi!', created_at: creation_time } params: { body: 'hi!', created_at: creation_time }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['notes'].first['body']).to eq('hi!') expect(json_response['notes'].first['body']).to eq('hi!')
expect(json_response['notes'].first['author']['username']).to eq(user.username) expect(json_response['notes'].first['author']['username']).to eq(user.username)
expect(Time.parse(json_response['notes'].first['created_at'])).to be_like_time(creation_time) expect(Time.parse(json_response['notes'].first['created_at'])).to be_like_time(creation_time)
...@@ -162,7 +162,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -162,7 +162,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", private_user), post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", private_user),
params: { body: 'Foo' } params: { body: 'Foo' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -181,7 +181,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -181,7 +181,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
end end
it 'raises 404 error' do it 'raises 404 error' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -191,7 +191,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -191,7 +191,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
end end
it 'raises 404 error' do it 'raises 404 error' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -203,7 +203,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -203,7 +203,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes", user), params: { body: 'Hello!' } "discussions/#{note.discussion_id}/notes", user), params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('Hello!') expect(json_response['body']).to eq('Hello!')
expect(json_response['type']).to eq('DiscussionNote') expect(json_response['type']).to eq('DiscussionNote')
end end
...@@ -212,7 +212,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -212,7 +212,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes", user) "discussions/#{note.discussion_id}/notes", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
context 'when the discussion is an individual note' do context 'when the discussion is an individual note' do
...@@ -225,13 +225,13 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -225,13 +225,13 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
if can_reply_to_individual_notes if can_reply_to_individual_notes
it 'creates a new discussion' do it 'creates a new discussion' do
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('hi!') expect(json_response['body']).to eq('hi!')
expect(json_response['type']).to eq('DiscussionNote') expect(json_response['type']).to eq('DiscussionNote')
end end
else else
it 'returns 400 bad request' do it 'returns 400 bad request' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
end end
...@@ -242,7 +242,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -242,7 +242,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user), params: { body: 'Hello!' } "discussions/#{note.discussion_id}/notes/#{note.id}", user), params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['body']).to eq('Hello!') expect(json_response['body']).to eq('Hello!')
end end
...@@ -251,14 +251,14 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -251,14 +251,14 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
"discussions/#{note.discussion_id}/notes/12345", user), "discussions/#{note.discussion_id}/notes/12345", user),
params: { body: 'Hello!' } params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a 400 bad request error if body not given' do it 'returns a 400 bad request error if body not given' do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user) "discussions/#{note.discussion_id}/notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -267,18 +267,18 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r ...@@ -267,18 +267,18 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name, can_r
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user) "discussions/#{note.discussion_id}/notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
# Check if note is really deleted # Check if note is really deleted
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user) "discussions/#{note.discussion_id}/notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a 404 error when note id not found' do it 'returns a 404 error when note id not found' do
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/12345", user) "discussions/#{note.discussion_id}/notes/12345", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
......
...@@ -6,7 +6,7 @@ shared_examples 'issuable participants endpoint' do ...@@ -6,7 +6,7 @@ shared_examples 'issuable participants endpoint' do
it 'returns participants' do it 'returns participants' do
get api("/projects/#{project.id}/#{area}/#{entity.iid}/participants", user) get api("/projects/#{project.id}/#{area}/#{entity.iid}/participants", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(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(entity.participants.size) expect(json_response.size).to eq(entity.participants.size)
...@@ -20,12 +20,12 @@ shared_examples 'issuable participants endpoint' do ...@@ -20,12 +20,12 @@ shared_examples 'issuable participants endpoint' do
it 'returns a 404 when iid does not exist' do it 'returns a 404 when iid does not exist' do
get api("/projects/#{project.id}/#{area}/999/participants", user) get api("/projects/#{project.id}/#{area}/999/participants", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a 404 when id is used instead of iid' do it 'returns a 404 when id is used instead of iid' do
get api("/projects/#{project.id}/#{area}/#{entity.id}/participants", user) get api("/projects/#{project.id}/#{area}/#{entity.id}/participants", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -82,7 +82,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -82,7 +82,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it "returns an array of notes" do it "returns an array of notes" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['body']).to eq(note.note) expect(json_response.first['body']).to eq(note.note)
...@@ -91,7 +91,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -91,7 +91,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it "returns a 404 error when noteable id not found" do it "returns a 404 error when noteable id not found" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/12345/notes", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/12345/notes", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns 404 when not authorized" do it "returns 404 when not authorized" do
...@@ -99,7 +99,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -99,7 +99,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -107,14 +107,14 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -107,14 +107,14 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it "returns a note by id" do it "returns a note by id" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/#{note.id}", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['body']).to eq(note.note) expect(json_response['body']).to eq(note.note)
end end
it "returns a 404 error if note not found" do it "returns a 404 error if note not found" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user) get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -122,7 +122,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -122,7 +122,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it "creates a new note" do it "creates a new note" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: { body: 'hi!' } post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: { body: 'hi!' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('hi!') expect(json_response['body']).to eq('hi!')
expect(json_response['author']['username']).to eq(user.username) expect(json_response['author']['username']).to eq(user.username)
end end
...@@ -130,13 +130,13 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -130,13 +130,13 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it "returns a 400 bad request error if body not given" do it "returns a 400 bad request error if body not given" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user) post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 401 unauthorized error if user not authenticated" do it "returns a 401 unauthorized error if user not authenticated" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes"), params: { body: 'hi!' } post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes"), params: { body: 'hi!' }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it "creates an activity event when a note is created", :sidekiq_might_not_need_inline do it "creates an activity event when a note is created", :sidekiq_might_not_need_inline do
...@@ -154,7 +154,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -154,7 +154,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
admin = create(:admin) admin = create(:admin)
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", admin), params: params post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", admin), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('hi!') expect(json_response['body']).to eq('hi!')
expect(json_response['author']['username']).to eq(admin.username) expect(json_response['author']['username']).to eq(admin.username)
expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
...@@ -167,7 +167,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -167,7 +167,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it 'sets the creation time on the new note' do it 'sets the creation time on the new note' do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: params post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('hi!') expect(json_response['body']).to eq('hi!')
expect(json_response['author']['username']).to eq(user.username) expect(json_response['author']['username']).to eq(user.username)
expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
...@@ -185,7 +185,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -185,7 +185,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user2), params: params post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user2), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('hi!') expect(json_response['body']).to eq('hi!')
expect(json_response['author']['username']).to eq(user2.username) expect(json_response['author']['username']).to eq(user2.username)
expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
...@@ -197,7 +197,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -197,7 +197,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it 'sets the creation time on the new note' do it 'sets the creation time on the new note' do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: params post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('hi!') expect(json_response['body']).to eq('hi!')
expect(json_response['author']['username']).to eq(user.username) expect(json_response['author']['username']).to eq(user.username)
expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time) expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
...@@ -212,7 +212,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -212,7 +212,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
parent.add_developer(user2) parent.add_developer(user2)
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user2), params: params post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user2), params: params
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq('hi!') expect(json_response['body']).to eq('hi!')
expect(json_response['author']['username']).to eq(user2.username) expect(json_response['author']['username']).to eq(user2.username)
expect(Time.parse(json_response['created_at'])).not_to be_like_time(creation_time) expect(Time.parse(json_response['created_at'])).not_to be_like_time(creation_time)
...@@ -226,7 +226,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -226,7 +226,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
parent.add_developer(private_user) parent.add_developer(private_user)
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user), params: { body: ':+1:' } post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user), params: { body: ':+1:' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq(':+1:') expect(json_response['body']).to eq(':+1:')
end end
end end
...@@ -235,7 +235,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -235,7 +235,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it 'creates a new note' do it 'creates a new note' do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: { body: ':+1:' } post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: { body: ':+1:' }
expect(response).to have_gitlab_http_status(201) expect(response).to have_gitlab_http_status(:created)
expect(json_response['body']).to eq(':+1:') expect(json_response['body']).to eq(':+1:')
end end
end end
...@@ -249,7 +249,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -249,7 +249,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user), post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user),
params: { body: 'Foo' } params: { body: 'Foo' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -259,7 +259,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -259,7 +259,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"notes/#{note.id}", user), params: { body: 'Hello!' } "notes/#{note.id}", user), params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['body']).to eq('Hello!') expect(json_response['body']).to eq('Hello!')
end end
...@@ -267,14 +267,14 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -267,14 +267,14 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user), put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user),
params: { body: 'Hello!' } params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a 400 bad request error if body not given' do it 'returns a 400 bad request error if body not given' do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"notes/#{note.id}", user) "notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
end end
...@@ -283,17 +283,17 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name| ...@@ -283,17 +283,17 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"notes/#{note.id}", user) "notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(204) expect(response).to have_gitlab_http_status(:no_content)
# Check if note is really deleted # Check if note is really deleted
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"notes/#{note.id}", user) "notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a 404 error when note id not found' do it 'returns a 404 error when note id not found' do
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user) delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it_behaves_like '412 response' do it_behaves_like '412 response' do
......
...@@ -6,7 +6,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ ...@@ -6,7 +6,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}", user), params: { resolved: true } "discussions/#{note.discussion_id}", user), params: { resolved: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['notes'].size).to eq(1) expect(json_response['notes'].size).to eq(1)
expect(json_response['notes'][0]['resolved']).to eq(true) expect(json_response['notes'][0]['resolved']).to eq(true)
end end
...@@ -15,7 +15,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ ...@@ -15,7 +15,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}", user), params: { resolved: false } "discussions/#{note.discussion_id}", user), params: { resolved: false }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['notes'].size).to eq(1) expect(json_response['notes'].size).to eq(1)
expect(json_response['notes'][0]['resolved']).to eq(false) expect(json_response['notes'][0]['resolved']).to eq(false)
end end
...@@ -24,21 +24,21 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ ...@@ -24,21 +24,21 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}", user) "discussions/#{note.discussion_id}", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 401 unauthorized error if user is not authenticated" do it "returns a 401 unauthorized error if user is not authenticated" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}"), params: { resolved: true } "discussions/#{note.discussion_id}"), params: { resolved: true }
expect(response).to have_gitlab_http_status(401) expect(response).to have_gitlab_http_status(:unauthorized)
end end
it "returns a 403 error if user resolves discussion of someone else" do it "returns a 403 error if user resolves discussion of someone else" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}", private_user), params: { resolved: true } "discussions/#{note.discussion_id}", private_user), params: { resolved: true }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
context 'when user does not have access to read the discussion' do context 'when user does not have access to read the discussion' do
...@@ -50,7 +50,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ ...@@ -50,7 +50,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}", private_user), params: { resolved: true } "discussions/#{note.discussion_id}", private_user), params: { resolved: true }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
...@@ -60,7 +60,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ ...@@ -60,7 +60,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user), params: { resolved: true } "discussions/#{note.discussion_id}/notes/#{note.id}", user), params: { resolved: true }
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['resolved']).to eq(true) expect(json_response['resolved']).to eq(true)
end end
...@@ -69,21 +69,21 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_ ...@@ -69,21 +69,21 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
"discussions/#{note.discussion_id}/notes/12345", user), "discussions/#{note.discussion_id}/notes/12345", user),
params: { body: 'Hello!' } params: { body: 'Hello!' }
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it 'returns a 400 bad request error if neither body nor resolved parameter is given' do it 'returns a 400 bad request error if neither body nor resolved parameter is given' do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user) "discussions/#{note.discussion_id}/notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
end end
it "returns a 403 error if user resolves note of someone else" do it "returns a 403 error if user resolves note of someone else" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\ put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", private_user), params: { resolved: true } "discussions/#{note.discussion_id}/notes/#{note.id}", private_user), params: { resolved: true }
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
end end
...@@ -13,7 +13,7 @@ shared_examples_for '400 response' do ...@@ -13,7 +13,7 @@ shared_examples_for '400 response' do
end end
it 'returns 400' do it 'returns 400' do
expect(response).to have_gitlab_http_status(400) expect(response).to have_gitlab_http_status(:bad_request)
if message.present? if message.present?
expect(json_response['message']).to eq(message) expect(json_response['message']).to eq(message)
...@@ -28,7 +28,7 @@ shared_examples_for '403 response' do ...@@ -28,7 +28,7 @@ shared_examples_for '403 response' do
end end
it 'returns 403' do it 'returns 403' do
expect(response).to have_gitlab_http_status(403) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
...@@ -41,7 +41,7 @@ shared_examples_for '404 response' do ...@@ -41,7 +41,7 @@ shared_examples_for '404 response' do
end end
it 'returns 404' do it 'returns 404' do
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
expect(json_response).to be_an Object expect(json_response).to be_an Object
if message.present? if message.present?
...@@ -60,7 +60,7 @@ shared_examples_for '412 response' do ...@@ -60,7 +60,7 @@ shared_examples_for '412 response' do
end end
it 'returns 412 with a JSON error' do it 'returns 412 with a JSON error' do
expect(response).to have_gitlab_http_status(412) expect(response).to have_gitlab_http_status(:precondition_failed)
expect(json_response).to eq('message' => '412 Precondition Failed') expect(json_response).to eq('message' => '412 Precondition Failed')
end end
end end
......
...@@ -33,7 +33,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do ...@@ -33,7 +33,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do
# At first, allow requests under the rate limit. # At first, allow requests under the rate limit.
requests_per_period.times do requests_per_period.times do
make_request(request_args) make_request(request_args)
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
# the last straw # the last straw
...@@ -43,7 +43,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do ...@@ -43,7 +43,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do
it 'allows requests after throttling and then waiting for the next period' do it 'allows requests after throttling and then waiting for the next period' do
requests_per_period.times do requests_per_period.times do
make_request(request_args) make_request(request_args)
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
expect_rejection { make_request(request_args) } expect_rejection { make_request(request_args) }
...@@ -51,7 +51,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do ...@@ -51,7 +51,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do
Timecop.travel(period.from_now) do Timecop.travel(period.from_now) do
requests_per_period.times do requests_per_period.times do
make_request(request_args) make_request(request_args)
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
expect_rejection { make_request(request_args) } expect_rejection { make_request(request_args) }
...@@ -61,18 +61,18 @@ shared_examples_for 'rate-limited token-authenticated requests' do ...@@ -61,18 +61,18 @@ shared_examples_for 'rate-limited token-authenticated requests' do
it 'counts requests from different users separately, even from the same IP' do it 'counts requests from different users separately, even from the same IP' do
requests_per_period.times do requests_per_period.times do
make_request(request_args) make_request(request_args)
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
# would be over the limit if this wasn't a different user # would be over the limit if this wasn't a different user
make_request(other_user_request_args) make_request(other_user_request_args)
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
it 'counts all requests from the same user, even via different IPs' do it 'counts all requests from the same user, even via different IPs' do
requests_per_period.times do requests_per_period.times do
make_request(request_args) make_request(request_args)
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4') expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4')
...@@ -83,7 +83,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do ...@@ -83,7 +83,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do
it 'logs RackAttack info into structured logs' do it 'logs RackAttack info into structured logs' do
requests_per_period.times do requests_per_period.times do
make_request(request_args) make_request(request_args)
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
arguments = { arguments = {
...@@ -112,7 +112,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do ...@@ -112,7 +112,7 @@ shared_examples_for 'rate-limited token-authenticated requests' do
it 'allows requests over the rate limit' do it 'allows requests over the rate limit' do
(1 + requests_per_period).times do (1 + requests_per_period).times do
make_request(request_args) make_request(request_args)
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
end end
end end
...@@ -160,7 +160,7 @@ shared_examples_for 'rate-limited web authenticated requests' do ...@@ -160,7 +160,7 @@ shared_examples_for 'rate-limited web authenticated requests' do
# At first, allow requests under the rate limit. # At first, allow requests under the rate limit.
requests_per_period.times do requests_per_period.times do
request_authenticated_web_url request_authenticated_web_url
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
# the last straw # the last straw
...@@ -170,7 +170,7 @@ shared_examples_for 'rate-limited web authenticated requests' do ...@@ -170,7 +170,7 @@ shared_examples_for 'rate-limited web authenticated requests' do
it 'allows requests after throttling and then waiting for the next period' do it 'allows requests after throttling and then waiting for the next period' do
requests_per_period.times do requests_per_period.times do
request_authenticated_web_url request_authenticated_web_url
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
expect_rejection { request_authenticated_web_url } expect_rejection { request_authenticated_web_url }
...@@ -178,7 +178,7 @@ shared_examples_for 'rate-limited web authenticated requests' do ...@@ -178,7 +178,7 @@ shared_examples_for 'rate-limited web authenticated requests' do
Timecop.travel(period.from_now) do Timecop.travel(period.from_now) do
requests_per_period.times do requests_per_period.times do
request_authenticated_web_url request_authenticated_web_url
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
expect_rejection { request_authenticated_web_url } expect_rejection { request_authenticated_web_url }
...@@ -188,20 +188,20 @@ shared_examples_for 'rate-limited web authenticated requests' do ...@@ -188,20 +188,20 @@ shared_examples_for 'rate-limited web authenticated requests' do
it 'counts requests from different users separately, even from the same IP' do it 'counts requests from different users separately, even from the same IP' do
requests_per_period.times do requests_per_period.times do
request_authenticated_web_url request_authenticated_web_url
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
# would be over the limit if this wasn't a different user # would be over the limit if this wasn't a different user
login_as(create(:user)) login_as(create(:user))
request_authenticated_web_url request_authenticated_web_url
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
it 'counts all requests from the same user, even via different IPs' do it 'counts all requests from the same user, even via different IPs' do
requests_per_period.times do requests_per_period.times do
request_authenticated_web_url request_authenticated_web_url
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4') expect_any_instance_of(Rack::Attack::Request).to receive(:ip).at_least(:once).and_return('1.2.3.4')
...@@ -212,7 +212,7 @@ shared_examples_for 'rate-limited web authenticated requests' do ...@@ -212,7 +212,7 @@ shared_examples_for 'rate-limited web authenticated requests' do
it 'logs RackAttack info into structured logs' do it 'logs RackAttack info into structured logs' do
requests_per_period.times do requests_per_period.times do
request_authenticated_web_url request_authenticated_web_url
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
arguments = { arguments = {
...@@ -241,7 +241,7 @@ shared_examples_for 'rate-limited web authenticated requests' do ...@@ -241,7 +241,7 @@ shared_examples_for 'rate-limited web authenticated requests' do
it 'allows requests over the rate limit' do it 'allows requests over the rate limit' do
(1 + requests_per_period).times do (1 + requests_per_period).times do
request_authenticated_web_url request_authenticated_web_url
expect(response).not_to have_http_status 429 expect(response).not_to have_gitlab_http_status(:too_many_requests)
end end
end end
end end
......
...@@ -8,7 +8,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ ...@@ -8,7 +8,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_
it "returns an array of resource label events" do it "returns an array of resource label events" do
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events", user) get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers expect(response).to include_pagination_headers
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['id']).to eq(event.id) expect(json_response.first['id']).to eq(event.id)
...@@ -17,7 +17,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ ...@@ -17,7 +17,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_
it "returns a 404 error when eventable id not found" do it "returns a 404 error when eventable id not found" do
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/12345/resource_label_events", user) get api("/#{parent_type}/#{parent.id}/#{eventable_type}/12345/resource_label_events", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns 404 when not authorized" do it "returns 404 when not authorized" do
...@@ -26,7 +26,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ ...@@ -26,7 +26,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events", private_user) get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events", private_user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -60,7 +60,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ ...@@ -60,7 +60,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_
it "returns a resource label event by id" do it "returns a resource label event by id" do
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{event.id}", user) get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{event.id}", user)
expect(response).to have_gitlab_http_status(200) expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq(event.id) expect(json_response['id']).to eq(event.id)
end end
...@@ -70,13 +70,13 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ ...@@ -70,13 +70,13 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{event.id}", private_user) get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{event.id}", private_user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
it "returns a 404 error if resource label event not found" do it "returns a 404 error if resource label event not found" do
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/12345", user) get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/12345", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
...@@ -88,7 +88,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_ ...@@ -88,7 +88,7 @@ shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_
it "returns a 404 error if cross-reference project is not accessible" do it "returns a 404 error if cross-reference project is not accessible" do
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{event.id}", user) get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{event.id}", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(:not_found)
end end
end end
end end
......
...@@ -69,7 +69,7 @@ shared_examples 'user login request with unique ip limit' do |success_status = 2 ...@@ -69,7 +69,7 @@ shared_examples 'user login request with unique ip limit' do |success_status = 2
it 'blocks user authenticating from two distinct ips' do it 'blocks user authenticating from two distinct ips' do
expect(request_from_ip('ip')).to have_gitlab_http_status(success_status) expect(request_from_ip('ip')).to have_gitlab_http_status(success_status)
expect(request_from_ip('ip2')).to have_gitlab_http_status(403) expect(request_from_ip('ip2')).to have_gitlab_http_status(:forbidden)
end end
end 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