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

Add latest changes from gitlab-org/gitlab@master

parent a53d2c37
......@@ -349,6 +349,8 @@ RSpec/HaveGitlabHttpStatus:
- 'ee/spec/requests/{groups,projects,repositories}/**/*'
- 'spec/requests/api/*/**/*.rb'
- 'ee/spec/requests/api/*/**/*.rb'
- 'spec/requests/api/[a-f]*.rb'
- 'ee/spec/requests/api/[a-f]*.rb'
Style/MultilineWhenThen:
Enabled: false
......
<script>
import _ from 'underscore';
import { throttle } from 'lodash';
import { mapActions, mapState, mapGetters } from 'vuex';
import { GlLoadingIcon } from '@gitlab/ui';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
......@@ -67,7 +67,7 @@ export default {
this.setFilter(target.value);
},
throttledFetchRepos: _.throttle(function fetch() {
throttledFetchRepos: throttle(function fetch() {
eventHub.$off('importAll');
this.fetchRepos();
}, reposFetchThrottleDelay),
......
......@@ -1808,11 +1808,7 @@ export default class Notes {
$editingNote.removeClass('is-editing fade-in-full').addClass('being-posted fade-in-half');
$editingNote
.find('.note-headline-meta a')
.html(
`<i class="fa fa-spinner fa-spin" aria-label="${__(
'Comment is being updated',
)}" aria-hidden="true"></i>`,
);
.html('<span class="spinner align-text-bottom"></span>');
// Make request to update comment on server
axios
......@@ -1825,7 +1821,7 @@ export default class Notes {
// Submission failed, revert back to original note
$noteBodyText.html(escape(cachedNoteBodyText));
$editingNote.removeClass('being-posted fade-in');
$editingNote.find('.fa.fa-spinner').remove();
$editingNote.find('.spinner').remove();
// Show Flash message about failure
this.updateNoteError();
......
......@@ -6,6 +6,7 @@ module Projects
RESERVED_ANNOTATIONS = %w(gitlab_incident_markdown title).freeze
GENERIC_ALERT_SUMMARY_ANNOTATIONS = %w(monitoring_tool service hosts).freeze
MARKDOWN_LINE_BREAK = " \n".freeze
INCIDENT_LABEL_NAME = IncidentManagement::CreateIssueService::INCIDENT_LABEL[:title].freeze
def full_title
[environment_name, alert_title].compact.join(': ')
......@@ -31,6 +32,18 @@ module Projects
end
end
def show_performance_dashboard_link?
gitlab_alert.present?
end
def show_incident_issues_link?
project.incident_management_setting&.create_issue?
end
def incident_issues_link
project_issues_url(project, label_name: INCIDENT_LABEL_NAME)
end
def starts_at
super&.rfc3339
end
......
# frozen_string_literal: true
module IncidentManagement
module Settings
def incident_management_setting
strong_memoize(:incident_management_setting) do
project.incident_management_setting ||
project.build_incident_management_setting
end
end
def process_issues?
incident_management_setting.create_issue?
end
end
end
......@@ -36,6 +36,8 @@ module Issues
execute_hooks(issue, 'close')
invalidate_cache_counts(issue, users: issue.assignees)
issue.update_project_counter_caches
store_first_mentioned_in_commit_at(issue, closed_via) if closed_via.is_a?(MergeRequest)
end
issue
......@@ -46,5 +48,17 @@ module Issues
def create_note(issue, current_commit)
SystemNoteService.change_status(issue, issue.project, current_user, issue.state, current_commit)
end
def store_first_mentioned_in_commit_at(issue, merge_request)
return unless Feature.enabled?(:store_first_mentioned_in_commit_on_issue_close, issue.project)
metrics = issue.metrics
return if metrics.nil? || metrics.first_mentioned_in_commit_at
first_commit_timestamp = merge_request.commits(limit: 1).first&.date
return unless first_commit_timestamp
metrics.update!(first_mentioned_in_commit_at: first_commit_timestamp)
end
end
end
......@@ -4,12 +4,14 @@ module Projects
module Alerting
class NotifyService < BaseService
include Gitlab::Utils::StrongMemoize
include IncidentManagement::Settings
def execute(token)
return forbidden unless alerts_service_activated?
return unauthorized unless valid_token?(token)
process_incident_issues
process_incident_issues if process_issues?
send_alert_email if send_email?
ServiceResponse.success
rescue Gitlab::Alerting::NotificationPayloadParser::BadPayloadError
......@@ -20,11 +22,21 @@ module Projects
delegate :alerts_service, :alerts_service_activated?, to: :project
def send_email?
incident_management_setting.send_email?
end
def process_incident_issues
IncidentManagement::ProcessAlertWorker
.perform_async(project.id, parsed_payload)
end
def send_alert_email
notification_service
.async
.prometheus_alerts_fired(project, [parsed_payload])
end
def parsed_payload
Gitlab::Alerting::NotificationPayloadParser.call(params.to_h)
end
......
......@@ -4,11 +4,11 @@
= render_dashboard_gold_trial(current_user)
.page-title-holder.d-flex.align-items-center
.page-title-holder.d-flex.align-items-start.flex-column.flex-sm-row.align-items-sm-center
%h1.page-title= _('Merge Requests')
- if current_user
.page-title-controls
.page-title-controls.ml-0.mb-3.ml-sm-auto.mb-sm-0
= render 'shared/new_project_item_select', path: 'merge_requests/new', label: "New merge request", with_feature_enabled: 'merge_requests', type: :merge_requests
.top-area
......
---
title: Send alert emails for generic incident alerts
merge_request: 24414
author:
type: added
---
title: Prevent "Select project to create merge request" button from overflowing out
of the viewport on mobile
merge_request: 25195
author:
type: fixed
---
title: Migrated from .fa-spinner to .spinner in 'app/assets/javascripts/notes.js
merge_request: 24916
author: Raihan Kabir (gitlab/rk4bir)
type: changed
......@@ -424,16 +424,10 @@ Take the following migration as an example:
```ruby
class DefaultRequestAccessGroups < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
change_column_default :namespaces, :request_access_enabled, true
end
def down
change_column_default :namespaces, :request_access_enabled, false
def change
change_column_default(:namespaces, :request_access_enabled, from: false, to: true)
end
end
```
......
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
......
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
......
# frozen_string_literal: true
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# See https://docs.gitlab.com/ee/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>]
......
......@@ -1674,6 +1674,9 @@ msgstr ""
msgid "Amount of time (in hours) that users are allowed to skip forced configuration of two-factor authentication"
msgstr ""
msgid "An alert has been triggered in %{project_path}."
msgstr ""
msgid "An application called %{link_to_client} is requesting access to your GitLab account."
msgstr ""
......@@ -12164,6 +12167,9 @@ msgstr ""
msgid "Metric was successfully updated."
msgstr ""
msgid "Metric:"
msgstr ""
msgid "MetricChart|Please select a metric"
msgstr ""
......@@ -21508,6 +21514,9 @@ msgstr ""
msgid "View group labels"
msgstr ""
msgid "View incident issues."
msgstr ""
msgid "View issue"
msgstr ""
......@@ -21532,6 +21541,9 @@ msgstr ""
msgid "View open merge request"
msgstr ""
msgid "View performance dashboard."
msgstr ""
msgid "View project"
msgstr ""
......@@ -21550,6 +21562,9 @@ msgstr ""
msgid "View the latest successful deployment to this environment"
msgstr ""
msgid "View the performance dashboard at"
msgstr ""
msgid "Viewing commit"
msgstr ""
......
import _ from 'underscore';
import { escape } from 'lodash';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import createStore from '~/notes/stores';
import issueNote from '~/notes/components/noteable_note.vue';
......@@ -98,7 +98,7 @@ describe('issue_note', () => {
setTimeout(() => {
expect(alertSpy).not.toHaveBeenCalled();
expect(wrapper.vm.note.note_html).toEqual(_.escape(noteBody));
expect(wrapper.vm.note.note_html).toEqual(escape(noteBody));
done();
}, 0);
});
......
......@@ -17,6 +17,12 @@ describe Gitlab::Alerting::Alert do
end
end
shared_context 'full query' do
before do
payload['generatorURL'] = 'http://localhost:9090/graph?g0.expr=vector%281%29'
end
end
shared_examples 'invalid alert' do
it 'is invalid' do
expect(alert).not_to be_valid
......@@ -180,10 +186,7 @@ describe Gitlab::Alerting::Alert do
context 'with gitlab alert' do
include_context 'gitlab alert'
before do
payload['generatorURL'] = 'http://localhost:9090/graph?g0.expr=vector%281%29'
end
include_context 'full query'
it { is_expected.to eq(gitlab_alert.full_query) }
end
......
......@@ -9,6 +9,15 @@ describe Projects::Prometheus::AlertPresenter do
let(:payload) { {} }
let(:alert) { create(:alerting_alert, project: project, payload: payload) }
shared_context 'gitlab alert' do
let(:gitlab_alert) { create(:prometheus_alert, project: project) }
let(:metric_id) { gitlab_alert.prometheus_metric_id }
let(:alert) do
create(:alerting_alert, project: project, metric_id: metric_id)
end
end
describe '#project_full_path' do
subject { presenter.project_full_path }
......@@ -145,13 +154,35 @@ describe Projects::Prometheus::AlertPresenter do
end
end
context 'with gitlab alert' do
let(:gitlab_alert) { create(:prometheus_alert, project: project) }
let(:metric_id) { gitlab_alert.prometheus_metric_id }
describe '#show_performance_dashboard_link?' do
subject { presenter.show_performance_dashboard_link? }
let(:alert) do
create(:alerting_alert, project: project, metric_id: metric_id)
it { is_expected.to be_falsey }
context 'with gitlab alert' do
include_context 'gitlab alert'
it { is_expected.to eq(true) }
end
end
describe '#show_incident_issues_link?' do
subject { presenter.show_incident_issues_link? }
it { is_expected.to be_falsey }
context 'create issue setting enabled' do
before do
create(:project_incident_management_setting, project: project, create_issue: true)
project.reload
end
it { is_expected.to eq(true) }
end
end
context 'with gitlab alert' do
include_context 'gitlab alert'
describe '#full_title' do
let(:query_title) do
......@@ -189,6 +220,17 @@ describe Projects::Prometheus::AlertPresenter do
it { is_expected.to eq(expected_link) }
end
describe '#incident_issues_link' do
let(:expected_link) do
Gitlab::Routing.url_helpers
.project_issues_url(project, label_name: described_class::INCIDENT_LABEL_NAME)
end
subject { presenter.incident_issues_link }
it { is_expected.to eq(expected_link) }
end
end
context 'without gitlab alert' do
......
......@@ -37,7 +37,7 @@ describe API::AccessRequests do
user = public_send(type)
get api("/#{source_type.pluralize}/#{source.id}/access_requests", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -47,7 +47,7 @@ describe API::AccessRequests do
it 'returns access requesters' do
get api("/#{source_type.pluralize}/#{source.id}/access_requests", maintainer)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -70,7 +70,7 @@ describe API::AccessRequests do
user = public_send(type)
post api("/#{source_type.pluralize}/#{source.id}/access_requests", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end.not_to change { source.requesters.count }
end
end
......@@ -82,7 +82,7 @@ describe API::AccessRequests do
expect do
post api("/#{source_type.pluralize}/#{source.id}/access_requests", access_requester)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end.not_to change { source.requesters.count }
end
end
......@@ -97,7 +97,7 @@ describe API::AccessRequests do
expect do
post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end.not_to change { source.requesters.count }
end
end
......@@ -106,7 +106,7 @@ describe API::AccessRequests do
expect do
post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end.to change { source.requesters.count }.by(1)
# User attributes
......@@ -137,7 +137,7 @@ describe API::AccessRequests do
user = public_send(type)
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -149,7 +149,7 @@ describe API::AccessRequests do
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", maintainer),
params: { access_level: Member::MAINTAINER }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end.to change { source.members.count }.by(1)
# User attributes
expect(json_response['id']).to eq(access_requester.id)
......@@ -168,7 +168,7 @@ describe API::AccessRequests do
expect do
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}/approve", maintainer)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end.not_to change { source.members.count }
end
end
......@@ -189,7 +189,7 @@ describe API::AccessRequests do
user = public_send(type)
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -200,7 +200,7 @@ describe API::AccessRequests do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", access_requester)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change { source.requesters.count }.by(-1)
end
end
......@@ -210,7 +210,7 @@ describe API::AccessRequests do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", maintainer)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change { source.requesters.count }.by(-1)
end
......@@ -219,7 +219,7 @@ describe API::AccessRequests do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{developer.id}", maintainer)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end.not_to change { source.requesters.count }
end
end
......@@ -229,7 +229,7 @@ describe API::AccessRequests do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}", maintainer)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end.not_to change { source.requesters.count }
end
end
......
......@@ -11,7 +11,7 @@ describe API::Appearance, 'Appearance' do
it "returns 403" do
get api("/application/appearance", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -19,7 +19,7 @@ describe API::Appearance, 'Appearance' do
it "returns appearance" do
get api("/application/appearance", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash
expect(json_response['description']).to eq('')
expect(json_response['email_header_and_footer_enabled']).to be(false)
......@@ -41,7 +41,7 @@ describe API::Appearance, 'Appearance' do
it "returns 403" do
put api("/application/appearance", user), params: { title: "Test" }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -54,7 +54,7 @@ describe API::Appearance, 'Appearance' do
new_project_guidelines: "Please read the FAQs for help."
}
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Hash
expect(json_response['description']).to eq('gitlab-test.example.com')
expect(json_response['email_header_and_footer_enabled']).to be(false)
......@@ -82,7 +82,7 @@ describe API::Appearance, 'Appearance' do
put api("/application/appearance", admin), params: settings
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
settings.each do |attribute, value|
expect(Appearance.current.public_send(attribute)).to eq(value)
end
......@@ -92,14 +92,14 @@ describe API::Appearance, 'Appearance' do
it "with message_font_color" do
put api("/application/appearance", admin), params: { message_font_color: "No Color" }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['message_font_color']).to contain_exactly('must be a valid color code')
end
it "with message_background_color" do
put api("/application/appearance", admin), params: { message_background_color: "#1" }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['message_background_color']).to contain_exactly('must be a valid color code')
end
end
......@@ -115,7 +115,7 @@ describe API::Appearance, 'Appearance' do
favicon: fixture_file_upload("spec/fixtures/dk.png", "image/png")
}
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['logo']).to eq("/uploads/-/system/appearance/logo/#{appearance.id}/dk.png")
expect(json_response['header_logo']).to eq("/uploads/-/system/appearance/header_logo/#{appearance.id}/dk.png")
expect(json_response['favicon']).to eq("/uploads/-/system/appearance/favicon/#{appearance.id}/dk.png")
......@@ -125,14 +125,14 @@ describe API::Appearance, 'Appearance' do
it "with string instead of file" do
put api("/application/appearance", admin), params: { logo: 'not-a-file.png' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq("logo is invalid")
end
it "with .svg file instead of .png" do
put api("/application/appearance", admin), params: { favicon: fixture_file_upload("spec/fixtures/logo_sample.svg", "image/svg") }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['favicon']).to contain_exactly("You are not allowed to upload \"svg\" files, allowed types: png, ico")
end
end
......
......@@ -16,7 +16,7 @@ describe API::Applications, :api do
application = Doorkeeper::Application.find_by(name: 'application_name', redirect_uri: 'http://application.url')
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to be_a Hash
expect(json_response['application_id']).to eq application.uid
expect(json_response['secret']).to eq application.secret
......@@ -29,7 +29,7 @@ describe API::Applications, :api do
post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://', scopes: '' }
end.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to be_a Hash
expect(json_response['message']['redirect_uri'][0]).to eq('must be an absolute URI.')
end
......@@ -39,7 +39,7 @@ describe API::Applications, :api do
post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'javascript://alert()', scopes: '' }
end.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to be_a Hash
expect(json_response['message']['redirect_uri'][0]).to eq('is forbidden by the server.')
end
......@@ -49,7 +49,7 @@ describe API::Applications, :api do
post api('/applications', admin_user), params: { redirect_uri: 'http://application.url', scopes: '' }
end.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to be_a Hash
expect(json_response['error']).to eq('name is missing')
end
......@@ -59,7 +59,7 @@ describe API::Applications, :api do
post api('/applications', admin_user), params: { name: 'application_name', scopes: '' }
end.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to be_a Hash
expect(json_response['error']).to eq('redirect_uri is missing')
end
......@@ -69,7 +69,7 @@ describe API::Applications, :api do
post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://application.url' }
end.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to be_a Hash
expect(json_response['error']).to eq('scopes is missing')
end
......@@ -79,7 +79,7 @@ describe API::Applications, :api do
post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://application.url', scopes: '', confidential: nil }
end.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response).to be_a Hash
expect(json_response['message']['confidential'].first).to eq('is not included in the list')
end
......@@ -91,7 +91,7 @@ describe API::Applications, :api do
post api('/applications', user), params: { name: 'application_name', redirect_uri: 'http://application.url', scopes: '' }
end.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -101,7 +101,7 @@ describe API::Applications, :api do
post api('/applications'), params: { name: 'application_name', redirect_uri: 'http://application.url' }
end.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......@@ -111,7 +111,7 @@ describe API::Applications, :api do
it 'can list application' do
get api('/applications', admin_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_a(Array)
end
end
......@@ -120,7 +120,7 @@ describe API::Applications, :api do
it 'cannot list application' do
get api('/applications', user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -128,7 +128,7 @@ describe API::Applications, :api do
it 'cannot list application' do
get api('/applications')
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......@@ -140,7 +140,7 @@ describe API::Applications, :api do
delete api("/applications/#{application.id}", admin_user)
end.to change { Doorkeeper::Application.count }.by(-1)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
end
......@@ -148,7 +148,7 @@ describe API::Applications, :api do
it 'cannot delete an application' do
delete api("/applications/#{application.id}", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -156,7 +156,7 @@ describe API::Applications, :api do
it 'cannot delete an application' do
delete api("/applications/#{application.id}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......
This diff is collapsed.
......@@ -35,7 +35,7 @@ describe API::Badges do
get api("/#{source_type.pluralize}/#{source.id}/badges", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(badges_count)
......@@ -80,7 +80,7 @@ describe API::Badges do
get api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(badge.name)
expect(json_response['id']).to eq(badge.id)
expect(json_response['link_url']).to eq(badge.link_url)
......@@ -120,7 +120,7 @@ describe API::Badges do
post api("/#{source_type.pluralize}/#{source.id}/badges", user),
params: { link_url: example_url, image_url: example_url2 }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -132,7 +132,7 @@ describe API::Badges do
post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer),
params: { name: example_name, link_url: example_url, image_url: example_url2 }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end.to change { source.badges.count }.by(1)
expect(json_response['name']).to eq(example_name)
......@@ -146,21 +146,21 @@ describe API::Badges do
post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer),
params: { link_url: example_url }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 when image_url is not given' do
post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer),
params: { image_url: example_url2 }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 when link_url or image_url is not valid' do
post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer),
params: { link_url: 'whatever', image_url: 'whatever' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -192,7 +192,7 @@ describe API::Badges do
put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", user),
params: { link_url: example_url }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -203,7 +203,7 @@ describe API::Badges do
put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer),
params: { name: example_name, link_url: example_url, image_url: example_url2 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq(example_name)
expect(json_response['link_url']).to eq(example_url)
expect(json_response['image_url']).to eq(example_url2)
......@@ -215,7 +215,7 @@ describe API::Badges do
put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer),
params: { link_url: 'whatever', image_url: 'whatever' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -240,7 +240,7 @@ describe API::Badges do
delete api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -251,7 +251,7 @@ describe API::Badges do
expect do
delete api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change { source.badges.count }.by(-1)
end
......@@ -263,7 +263,7 @@ describe API::Badges do
it 'returns 404 if badge does not exist' do
delete api("/#{source_type.pluralize}/#{source.id}/badges/123", maintainer)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -290,7 +290,7 @@ describe API::Badges do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=#{example_url}&image_url=#{example_url2}", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -300,7 +300,7 @@ describe API::Badges do
it 'gets the rendered badge values' do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=#{example_url}&image_url=#{example_url2}", maintainer)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.keys).to contain_exactly('name', 'link_url', 'rendered_link_url', 'image_url', 'rendered_image_url')
expect(json_response['link_url']).to eq(example_url)
......@@ -313,19 +313,19 @@ describe API::Badges do
it 'returns 400 when link_url is not given' do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=#{example_url}", maintainer)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 when image_url is not given' do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?image_url=#{example_url}", maintainer)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns 400 when link_url or image_url is not valid' do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=whatever&image_url=whatever", maintainer)
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -335,7 +335,7 @@ describe API::Badges do
it 'cannot delete badges owned by the project group' do
delete api("/projects/#{project.id}/badges/#{project_group.badges.first.id}", maintainer)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......
......@@ -45,7 +45,7 @@ describe API::Boards do
post api(url, user), params: { label_id: group_label.id }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['label']['name']).to eq(group_label.title)
expect(json_response['position']).to eq(3)
end
......@@ -60,7 +60,7 @@ describe API::Boards do
post api(url, user), params: { label_id: group_label.id }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['label']['name']).to eq(group_label.title)
end
end
......@@ -78,7 +78,7 @@ describe API::Boards do
post api(url, user), params: { label_id: group_label.id }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['label']['name']).to eq(group_label.title)
end
end
......
......@@ -31,7 +31,7 @@ describe API::Branches do
it 'returns the repository branches' do
get api(route, current_user), params: { per_page: 100 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branches')
expect(response).to include_pagination_headers
branch_names = json_response.map { |x| x['name'] }
......@@ -51,7 +51,7 @@ describe API::Branches do
get api(route, current_user), params: { per_page: 2 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
check_merge_status(json_response)
end
......@@ -59,7 +59,7 @@ describe API::Branches do
it 'merge status matches reality on paginated input' do
get api(route, current_user), params: { per_page: 20, page: 2 }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
check_merge_status(json_response)
end
......@@ -155,14 +155,14 @@ describe API::Branches do
it 'returns 204 No Content' do
head api(route, user)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
expect(response.body).to be_empty
end
it 'returns 404 Not Found' do
head api("/projects/#{project_id}/repository/branches/unknown", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to be_empty
end
end
......@@ -170,7 +170,7 @@ describe API::Branches do
it 'returns the repository branch' do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq(CGI.unescape(branch_name))
end
......@@ -298,7 +298,7 @@ describe API::Branches do
it 'protects a single branch' do
put api(route, current_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq(CGI.unescape(branch_name))
expect(json_response['protected']).to eq(true)
......@@ -307,7 +307,7 @@ describe API::Branches do
it 'protects a single branch and developers can push' do
put api(route, current_user), params: { developers_can_push: true }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq(CGI.unescape(branch_name))
expect(json_response['protected']).to eq(true)
......@@ -318,7 +318,7 @@ describe API::Branches do
it 'protects a single branch and developers can merge' do
put api(route, current_user), params: { developers_can_merge: true }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq(CGI.unescape(branch_name))
expect(json_response['protected']).to eq(true)
......@@ -329,7 +329,7 @@ describe API::Branches do
it 'protects a single branch and developers can push and merge' do
put api(route, current_user), params: { developers_can_push: true, developers_can_merge: true }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq(CGI.unescape(branch_name))
expect(json_response['protected']).to eq(true)
......@@ -428,7 +428,7 @@ describe API::Branches do
put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user),
params: { developers_can_push: false, developers_can_merge: false }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq(protected_branch.name)
expect(json_response['protected']).to eq(true)
......@@ -446,7 +446,7 @@ describe API::Branches do
put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user),
params: { developers_can_push: true, developers_can_merge: true }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq(protected_branch.name)
expect(json_response['protected']).to eq(true)
......@@ -465,7 +465,7 @@ describe API::Branches do
it 'unprotects a single branch' do
put api(route, current_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq(CGI.unescape(branch_name))
expect(json_response['protected']).to eq(false)
......@@ -559,7 +559,7 @@ describe API::Branches do
it 'creates a new branch' do
post api(route, current_user), params: { branch: 'feature1', ref: branch_sha }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(response).to match_response_schema('public_api/v4/branch')
expect(json_response['name']).to eq('feature1')
expect(json_response['commit']['id']).to eq(branch_sha)
......@@ -604,25 +604,25 @@ describe API::Branches do
it 'returns 400 if branch name is invalid' do
post api(route, user), params: { branch: 'new design', ref: branch_sha }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Branch name is invalid')
end
it 'returns 400 if branch already exists', :clean_gitlab_redis_cache do
post api(route, user), params: { branch: 'new_design1', ref: branch_sha }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
post api(route, user), params: { branch: 'new_design1', ref: branch_sha }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Branch already exists')
end
it 'returns 400 if ref name is invalid' do
post api(route, user), params: { branch: 'new_design3', ref: 'foo' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']).to eq('Invalid reference name: new_design3')
end
end
......@@ -637,19 +637,19 @@ describe API::Branches do
it 'removes branch' do
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'removes a branch with dots in the branch name' do
delete api("/projects/#{project.id}/repository/branches/#{branch_with_dot.name}", user)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'returns 404 if branch not exists' do
delete api("/projects/#{project.id}/repository/branches/foobar", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
context 'when the branch refname is invalid' do
......@@ -676,14 +676,14 @@ describe API::Branches do
it 'returns 202 with json body' do
delete api("/projects/#{project.id}/repository/merged_branches", user)
expect(response).to have_gitlab_http_status(202)
expect(response).to have_gitlab_http_status(:accepted)
expect(json_response['message']).to eql('202 Accepted')
end
it 'returns a 403 error if guest' do
delete api("/projects/#{project.id}/repository/merged_branches", guest)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -13,7 +13,7 @@ describe API::BroadcastMessages do
get api('/broadcast_messages')
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_kind_of(Array)
expect(json_response.first.keys)
......@@ -25,7 +25,7 @@ describe API::BroadcastMessages do
it 'returns the specified message' do
get api("/broadcast_messages/#{message.id}")
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['id']).to eq message.id
expect(json_response.keys)
.to match_array(%w(id message starts_at ends_at color font active target_path broadcast_type))
......@@ -36,13 +36,13 @@ describe API::BroadcastMessages do
it 'returns a 401 for anonymous users' do
post api('/broadcast_messages'), params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns a 403 for users' do
post api('/broadcast_messages', user), params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'as an admin' do
......@@ -52,7 +52,7 @@ describe API::BroadcastMessages do
post api('/broadcast_messages', admin), params: attrs
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq 'message is missing'
end
......@@ -61,7 +61,7 @@ describe API::BroadcastMessages do
travel_to(time) do
post api('/broadcast_messages', admin), params: { message: 'Test message' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z'
expect(json_response['ends_at']).to eq '2016-07-02T11:11:12.000Z'
end
......@@ -72,7 +72,7 @@ describe API::BroadcastMessages do
post api('/broadcast_messages', admin), params: attrs
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['color']).to eq attrs[:color]
expect(json_response['font']).to eq attrs[:font]
end
......@@ -82,7 +82,7 @@ describe API::BroadcastMessages do
post api('/broadcast_messages', admin), params: attrs
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['target_path']).to eq attrs[:target_path]
end
......@@ -91,7 +91,7 @@ describe API::BroadcastMessages do
post api('/broadcast_messages', admin), params: attrs
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['broadcast_type']).to eq attrs[:broadcast_type]
end
......@@ -100,7 +100,7 @@ describe API::BroadcastMessages do
post api('/broadcast_messages', admin), params: attrs
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['broadcast_type']).to eq 'banner'
end
......@@ -109,7 +109,7 @@ describe API::BroadcastMessages do
post api('/broadcast_messages', admin), params: attrs
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -119,14 +119,14 @@ describe API::BroadcastMessages do
put api("/broadcast_messages/#{message.id}"),
params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns a 403 for users' do
put api("/broadcast_messages/#{message.id}", user),
params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'as an admin' do
......@@ -135,7 +135,7 @@ describe API::BroadcastMessages do
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['color']).to eq attrs[:color]
expect(json_response['font']).to eq attrs[:font]
end
......@@ -147,7 +147,7 @@ describe API::BroadcastMessages do
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z'
expect(json_response['ends_at']).to eq '2016-07-02T13:11:12.000Z'
end
......@@ -158,7 +158,7 @@ describe API::BroadcastMessages do
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect { message.reload }.to change { message.message }.to('new message')
end
......@@ -167,7 +167,7 @@ describe API::BroadcastMessages do
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['target_path']).to eq attrs[:target_path]
end
......@@ -176,7 +176,7 @@ describe API::BroadcastMessages do
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['broadcast_type']).to eq attrs[:broadcast_type]
end
......@@ -185,7 +185,7 @@ describe API::BroadcastMessages do
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -195,14 +195,14 @@ describe API::BroadcastMessages do
delete api("/broadcast_messages/#{message.id}"),
params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns a 403 for users' do
delete api("/broadcast_messages/#{message.id}", user),
params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it_behaves_like '412 response' do
......@@ -213,7 +213,7 @@ describe API::BroadcastMessages do
expect do
delete api("/broadcast_messages/#{message.id}", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change { BroadcastMessage.count }.by(-1)
end
end
......
......@@ -37,7 +37,7 @@ describe API::CommitStatuses do
end
it 'returns latest commit statuses' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
......@@ -53,7 +53,7 @@ describe API::CommitStatuses do
end
it 'returns all commit statuses' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status1.id, status2.id,
......@@ -68,7 +68,7 @@ describe API::CommitStatuses do
end
it 'returns latest commit statuses for specific ref' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status3.id, status5.id)
......@@ -81,7 +81,7 @@ describe API::CommitStatuses do
end
it 'return latest commit statuses for specific name' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status4.id, status5.id)
......@@ -108,7 +108,7 @@ describe API::CommitStatuses do
end
it "does not return project commits" do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -118,7 +118,7 @@ describe API::CommitStatuses do
end
it "does not return project commits" do
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......@@ -134,7 +134,7 @@ describe API::CommitStatuses do
it 'creates commit status' do
post api(post_url, developer), params: { state: status }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['sha']).to eq(commit.id)
expect(json_response['status']).to eq(status)
expect(json_response['name']).to eq('default')
......@@ -162,7 +162,7 @@ describe API::CommitStatuses do
job = pipeline.statuses.find_by_name(json_response['name'])
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(job.status).to eq('pending')
expect(job.stage_idx).to eq(GenericCommitStatus::EXTERNAL_STAGE_IDX)
end
......@@ -189,7 +189,7 @@ describe API::CommitStatuses do
it "to #{status}" do
expect { post api(post_url, developer), params: { state: status } }.not_to change { CommitStatus.count }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['status']).to eq(status)
end
end
......@@ -211,7 +211,7 @@ describe API::CommitStatuses do
it 'creates commit status' do
subject
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['sha']).to eq(commit.id)
expect(json_response['status']).to eq('success')
expect(json_response['name']).to eq('coverage')
......@@ -227,7 +227,7 @@ describe API::CommitStatuses do
it 'sets head pipeline' do
subject
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(merge_request.reload.head_pipeline).not_to be_nil
end
end
......@@ -254,7 +254,7 @@ describe API::CommitStatuses do
end
it 'updates a commit status' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['sha']).to eq(commit.id)
expect(json_response['status']).to eq('success')
expect(json_response['name']).to eq('coverage')
......@@ -300,7 +300,7 @@ describe API::CommitStatuses do
end
it 'correctly posts a new commit status' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['sha']).to eq(commit.id)
expect(json_response['status']).to eq('success')
end
......@@ -318,7 +318,7 @@ describe API::CommitStatuses do
end
it 'does not create commit status' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -328,7 +328,7 @@ describe API::CommitStatuses do
end
it 'does not create commit status' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -342,7 +342,7 @@ describe API::CommitStatuses do
let(:user) { developer }
it 'does not create commit status' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -350,7 +350,7 @@ describe API::CommitStatuses do
let(:user) { create_user(:maintainer) }
it 'creates commit status' do
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
end
end
......@@ -363,7 +363,7 @@ describe API::CommitStatuses do
end
it 'returns not found error' do
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -376,7 +376,7 @@ describe API::CommitStatuses do
end
it 'responds with bad request status and validation errors' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['target_url'])
.to include 'is blocked: Only allowed schemes are http, https'
end
......@@ -391,7 +391,7 @@ describe API::CommitStatuses do
end
it 'responds with bad request status and validation errors' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['target_url'])
.to include 'is blocked: Only allowed schemes are http, https'
end
......@@ -407,7 +407,7 @@ describe API::CommitStatuses do
end
it 'responds with bad request status and validation errors' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['message']['name'])
.to include 'has already been taken'
end
......@@ -420,7 +420,7 @@ describe API::CommitStatuses do
end
it 'does not create commit status' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -430,7 +430,7 @@ describe API::CommitStatuses do
end
it 'does not create commit status' do
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -440,7 +440,7 @@ describe API::CommitStatuses do
end
it 'does not create commit status' do
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
end
......
This diff is collapsed.
......@@ -51,7 +51,7 @@ describe API::DeployKeys do
it 'returns array of ssh keys' do
get api("/projects/#{project.id}/deploy_keys", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.first['title']).to eq(deploy_key.title)
......@@ -62,14 +62,14 @@ describe API::DeployKeys do
it 'returns a single key' do
get api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['title']).to eq(deploy_key.title)
end
it 'returns 404 Not Found with invalid ID' do
get api("/projects/#{project.id}/deploy_keys/404", admin)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -77,14 +77,14 @@ describe API::DeployKeys do
it 'does not create an invalid ssh key' do
post api("/projects/#{project.id}/deploy_keys", admin), params: { title: 'invalid key' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('key is missing')
end
it 'does not create a key without title' do
post api("/projects/#{project.id}/deploy_keys", admin), params: { key: 'some key' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eq('title is missing')
end
......@@ -105,7 +105,7 @@ describe API::DeployKeys do
post api("/projects/#{project.id}/deploy_keys", admin), params: { key: deploy_key.key, title: deploy_key.title }
end.not_to change { project.deploy_keys.count }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'joins an existing ssh key to a new project' do
......@@ -113,7 +113,7 @@ describe API::DeployKeys do
post api("/projects/#{project2.id}/deploy_keys", admin), params: { key: deploy_key.key, title: deploy_key.title }
end.to change { project2.deploy_keys.count }.by(1)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
end
it 'accepts can_push parameter' do
......@@ -121,7 +121,7 @@ describe API::DeployKeys do
post api("/projects/#{project.id}/deploy_keys", admin), params: key_attrs
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['can_push']).to eq(true)
end
end
......@@ -139,7 +139,7 @@ describe API::DeployKeys do
it 'does not update a public deploy key' do
expect { subject }.not_to change(deploy_key, :title)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -151,12 +151,12 @@ describe API::DeployKeys do
it 'updates the title of the deploy key' do
expect { subject }.to change { deploy_key.reload.title }.to 'new title'
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'updates can_push of deploy_keys_project' do
expect { subject }.to change { deploy_keys_project.reload.can_push }.from(false).to(true)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
......@@ -169,12 +169,12 @@ describe API::DeployKeys do
it 'updates the title of the deploy key' do
expect { subject }.to change { deploy_key.reload.title }.to 'new title'
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'updates can_push of deploy_keys_project' do
expect { subject }.to change { deploy_keys_project.reload.can_push }.from(false).to(true)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
context 'invalid title' do
......@@ -182,7 +182,7 @@ describe API::DeployKeys do
it 'does not update the title of the deploy key' do
expect { subject }.not_to change { deploy_key.reload.title }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -200,12 +200,12 @@ describe API::DeployKeys do
it 'updates the title of the deploy key' do
expect { subject }.to change { deploy_key.reload.title }.to 'new title'
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'updates can_push of deploy_keys_project' do
expect { subject }.to change { deploy_keys_project.reload.can_push }.from(false).to(true)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -222,12 +222,12 @@ describe API::DeployKeys do
it 'does not update the title of the deploy key' do
expect { subject }.not_to change { deploy_key.reload.title }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'updates can_push of deploy_keys_project' do
expect { subject }.to change { deploy_keys_project.reload.can_push }.from(false).to(true)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
end
end
......@@ -242,7 +242,7 @@ describe API::DeployKeys do
expect do
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change { project.deploy_keys.count }.by(-1)
end
......@@ -251,7 +251,7 @@ describe API::DeployKeys do
expect do
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.not_to change { DeployKey.count }
end
end
......@@ -264,7 +264,7 @@ describe API::DeployKeys do
expect do
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.to change { DeployKey.count }.by(-1)
end
end
......@@ -278,7 +278,7 @@ describe API::DeployKeys do
expect do
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end.not_to change { DeployKey.count }
end
end
......@@ -287,7 +287,7 @@ describe API::DeployKeys do
it 'returns 404 Not Found with invalid ID' do
delete api("/projects/#{project.id}/deploy_keys/404", admin)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it_behaves_like '412 response' do
......@@ -304,7 +304,7 @@ describe API::DeployKeys do
post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", admin)
end.to change { project2.deploy_keys.count }.from(0).to(1)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['id']).to eq(deploy_key.id)
end
end
......@@ -313,7 +313,7 @@ describe API::DeployKeys do
it 'returns a 404 error' do
post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -20,7 +20,7 @@ describe API::Deployments do
it 'returns projects deployments sorted by id asc' do
get api("/projects/#{project.id}/deployments", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
......@@ -74,7 +74,7 @@ describe API::Deployments do
let(:order_by) { 'wrong_sorting_value' }
it 'returns error' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
......@@ -82,7 +82,7 @@ describe API::Deployments do
let(:sort) { 'wrong_sorting_direction' }
it 'returns error' do
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
......@@ -92,7 +92,7 @@ describe API::Deployments do
it 'returns a 404 status code' do
get api("/projects/#{project.id}/deployments", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -105,7 +105,7 @@ describe API::Deployments do
it 'returns the projects deployment' do
get api("/projects/#{project.id}/deployments/#{deployment.id}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['sha']).to match /\A\h{40}\z/
expect(json_response['id']).to eq(deployment.id)
end
......@@ -115,7 +115,7 @@ describe API::Deployments do
it 'returns a 404 status code' do
get api("/projects/#{project.id}/deployments/#{deployment.id}", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -159,7 +159,7 @@ describe API::Deployments do
}
)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['sha']).to eq(sha)
expect(json_response['ref']).to eq('master')
......@@ -178,7 +178,7 @@ describe API::Deployments do
}
)
expect(response).to have_gitlab_http_status(500)
expect(response).to have_gitlab_http_status(:internal_server_error)
end
it 'links any merged merge requests to the deployment', :sidekiq_inline do
......@@ -228,7 +228,7 @@ describe API::Deployments do
}
)
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['sha']).to eq(sha)
expect(json_response['ref']).to eq('master')
......@@ -312,7 +312,7 @@ describe API::Deployments do
}
)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -341,7 +341,7 @@ describe API::Deployments do
params: { status: 'success' }
)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'updates a deployment without an associated build' do
......@@ -350,7 +350,7 @@ describe API::Deployments do
params: { status: 'success' }
)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('success')
end
......@@ -390,7 +390,7 @@ describe API::Deployments do
params: { status: 'success' }
)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'updates a deployment without an associated build' do
......@@ -399,7 +399,7 @@ describe API::Deployments do
params: { status: 'success' }
)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['status']).to eq('success')
end
end
......@@ -411,7 +411,7 @@ describe API::Deployments do
params: { status: 'success' }
)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -428,7 +428,7 @@ describe API::Deployments do
it 'returns a 404 status code' do
subject
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -443,7 +443,7 @@ describe API::Deployments do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.map { |d| d['id'] }).to contain_exactly(merge_request1.id, merge_request2.id)
end
......@@ -451,7 +451,7 @@ describe API::Deployments do
it 'returns an empty array' do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to eq([])
end
end
......@@ -468,7 +468,7 @@ describe API::Deployments do
it 'succeeds', :aggregate_failures do
subject
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(1)
end
......
......@@ -58,7 +58,7 @@ describe API::Discussions do
post api("/projects/#{project.id}/merge_requests/#{noteable['iid']}/discussions", user),
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
......
......@@ -10,7 +10,7 @@ describe 'doorkeeper access' do
describe "unauthenticated" do
it "returns authentication success" do
get api("/user"), params: { access_token: token.token }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
include_examples 'user login request with unique ip limit' do
......@@ -23,14 +23,14 @@ describe 'doorkeeper access' do
describe "when token invalid" do
it "returns authentication error" do
get api("/user"), params: { access_token: "123a" }
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
describe "authorization by OAuth token" do
it "returns authentication success" do
get api("/user", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
include_examples 'user login request with unique ip limit' do
......@@ -44,7 +44,7 @@ describe 'doorkeeper access' do
it 'returns 403 response' do
get api("/user"), params: { access_token: token.token }
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......
......@@ -27,7 +27,7 @@ describe API::Environments do
get api("/projects/#{project.id}/environments", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -43,7 +43,7 @@ describe API::Environments do
it 'returns environment by name' do
get api("/projects/#{project.id}/environments?name=#{environment.name}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -53,7 +53,7 @@ describe API::Environments do
it 'returns no environment by non-existent name' do
get api("/projects/#{project.id}/environments?name=test", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(0)
......@@ -62,7 +62,7 @@ describe API::Environments do
it 'returns environments by name_like' do
get api("/projects/#{project.id}/environments?search=envir", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(2)
......@@ -71,7 +71,7 @@ describe API::Environments do
it 'returns no environment by non-existent name_like' do
get api("/projects/#{project.id}/environments?search=test", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(0)
......@@ -83,7 +83,7 @@ describe API::Environments do
it 'returns a 404 status code' do
get api("/projects/#{project.id}/environments", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -93,7 +93,7 @@ describe API::Environments do
it 'creates a environment with valid params' do
post api("/projects/#{project.id}/environments", user), params: { name: "mepmep" }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq('mepmep')
expect(json_response['slug']).to eq('mepmep')
expect(json_response['external']).to be nil
......@@ -102,19 +102,19 @@ describe API::Environments do
it 'requires name to be passed' do
post api("/projects/#{project.id}/environments", user), params: { external_url: 'test.gitlab.com' }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns a 400 if environment already exists' do
post api("/projects/#{project.id}/environments", user), params: { name: environment.name }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
end
it 'returns a 400 if slug is specified' do
post api("/projects/#{project.id}/environments", user), params: { name: "foo", slug: "foo" }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed")
end
end
......@@ -123,7 +123,7 @@ describe API::Environments do
it 'rejects the request' do
post api("/projects/#{project.id}/environments", non_member), params: { name: 'gitlab.com' }
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
it 'returns a 400 when the required params are missing' do
......@@ -138,7 +138,7 @@ describe API::Environments do
put api("/projects/#{project.id}/environments/#{environment.id}", user),
params: { name: 'Mepmep', external_url: url }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('Mepmep')
expect(json_response['external_url']).to eq(url)
end
......@@ -148,7 +148,7 @@ describe API::Environments do
api_url = api("/projects/#{project.id}/environments/#{environment.id}", user)
put api_url, params: { slug: slug + "-foo" }
expect(response).to have_gitlab_http_status(400)
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed")
end
......@@ -157,7 +157,7 @@ describe API::Environments do
put api("/projects/#{project.id}/environments/#{environment.id}", user),
params: { name: 'Mepmep' }
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['name']).to eq('Mepmep')
expect(json_response['external_url']).to eq(url)
end
......@@ -165,7 +165,7 @@ describe API::Environments do
it 'returns a 404 if the environment does not exist' do
put api("/projects/#{project.id}/environments/12345", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
......@@ -174,13 +174,13 @@ describe API::Environments do
it 'returns a 200 for an existing environment' do
delete api("/projects/#{project.id}/environments/#{environment.id}", user)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
it 'returns a 404 for non existing id' do
delete api("/projects/#{project.id}/environments/12345", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found')
end
......@@ -193,7 +193,7 @@ describe API::Environments do
it 'rejects the request' do
delete api("/projects/#{project.id}/environments/#{environment.id}", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -208,7 +208,7 @@ describe API::Environments do
end
it 'returns a 200' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'actually stops the environment' do
......@@ -219,7 +219,7 @@ describe API::Environments do
it 'returns a 404 for non existing id' do
post api("/projects/#{project.id}/environments/12345/stop", user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 Not found')
end
end
......@@ -228,7 +228,7 @@ describe API::Environments do
it 'rejects the request' do
post api("/projects/#{project.id}/environments/#{environment.id}/stop", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......@@ -240,7 +240,7 @@ describe API::Environments do
get api("/projects/#{project.id}/environments/#{environment.id}", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/environment')
end
end
......@@ -249,7 +249,7 @@ describe API::Environments do
it 'returns a 404 status code' do
get api("/projects/#{project.id}/environments/#{environment.id}", non_member)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
......
......@@ -16,7 +16,7 @@ describe API::Events do
it 'returns authentication error' do
get api('/events')
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
......@@ -24,7 +24,7 @@ describe API::Events do
it 'returns users events' do
get api('/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31', user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -36,7 +36,7 @@ describe API::Events do
get api('/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31&scope=all', user)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(2)
......@@ -50,7 +50,7 @@ describe API::Events do
it 'returns users events' do
get api('/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31', personal_access_token: token)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -63,7 +63,7 @@ describe API::Events do
it 'returns a "403" response' do
get api('/events', personal_access_token: token_without_scopes)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
......@@ -76,7 +76,7 @@ describe API::Events do
get api("/users/#{user.id}/events", non_member)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty
end
end
......@@ -90,7 +90,7 @@ describe API::Events do
get api("/users/#{user.id}/events", personal_access_token: non_member_token)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty
end
end
......@@ -99,7 +99,7 @@ describe API::Events do
it 'accepts a username' do
get api("/users/#{user.username}/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(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -108,7 +108,7 @@ describe API::Events do
it 'returns the events' do
get api("/users/#{user.id}/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(json_response).to be_an Array
expect(json_response.size).to eq(1)
......@@ -127,7 +127,7 @@ describe API::Events do
end
it 'responds with HTTP 200 OK' do
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
end
it 'includes the push payload as a Hash' do
......@@ -177,7 +177,7 @@ describe API::Events do
it 'returns no user events' do
get api("/users/#{user.username}/events?scope=all")
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_an Array
expect(json_response.size).to eq(0)
end
......@@ -188,7 +188,7 @@ describe API::Events do
it 'returns a 404 error if not found' do
get api('/users/42/events', user)
expect(response).to have_gitlab_http_status(404)
expect(response).to have_gitlab_http_status(:not_found)
expect(json_response['message']).to eq('404 User Not Found')
end
end
......
......@@ -46,19 +46,19 @@ describe API::Features do
it 'returns a 401 for anonymous users' do
get api('/features')
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns a 403 for users' do
get api('/features', user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
it 'returns the feature list for admins' do
get api('/features', admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to match_array(expected_features)
end
end
......@@ -70,20 +70,20 @@ describe API::Features do
it 'returns a 401 for anonymous users' do
post api("/features/#{feature_name}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns a 403 for users' do
post api("/features/#{feature_name}", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
context 'when passed value=true' do
it 'creates an enabled feature' do
post api("/features/#{feature_name}", admin), params: { value: 'true' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'on',
......@@ -93,7 +93,7 @@ describe API::Features do
it 'creates an enabled feature for the given Flipper group when passed feature_group=perf_team' do
post api("/features/#{feature_name}", admin), params: { value: 'true', feature_group: 'perf_team' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'conditional',
......@@ -106,7 +106,7 @@ describe API::Features do
it 'creates an enabled feature for the given user when passed user=username' do
post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'conditional',
......@@ -119,7 +119,7 @@ describe API::Features do
it 'creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team' do
post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username, feature_group: 'perf_team' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response['name']).to eq('my_feature')
expect(json_response['state']).to eq('conditional')
expect(json_response['gates']).to contain_exactly(
......@@ -137,7 +137,7 @@ describe API::Features do
it 'sets the feature gate' do
post api("/features/#{feature_name}", admin), params: { value: 'true', project: project.full_path }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'conditional',
......@@ -152,7 +152,7 @@ describe API::Features do
it 'sets no new values' do
post api("/features/#{feature_name}", admin), params: { value: 'true', project: 'mep/to/the/mep/mep' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
"name" => "my_feature",
"state" => "off",
......@@ -171,7 +171,7 @@ describe API::Features do
post api("/features/#{feature_name}", admin), params: { value: 'true', group: group.full_path }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'conditional',
......@@ -186,7 +186,7 @@ describe API::Features do
it 'sets no new values and keeps the feature disabled' do
post api("/features/#{feature_name}", admin), params: { value: 'true', group: 'not/a/group' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
"name" => "my_feature",
"state" => "off",
......@@ -201,7 +201,7 @@ describe API::Features do
it 'creates a feature with the given percentage if passed an integer' do
post api("/features/#{feature_name}", admin), params: { value: '50' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'conditional',
......@@ -223,7 +223,7 @@ describe API::Features do
it 'enables the feature' do
post api("/features/#{feature_name}", admin), params: { value: 'true' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'on',
......@@ -233,7 +233,7 @@ describe API::Features do
it 'enables the feature for the given Flipper group when passed feature_group=perf_team' do
post api("/features/#{feature_name}", admin), params: { value: 'true', feature_group: 'perf_team' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'conditional',
......@@ -246,7 +246,7 @@ describe API::Features do
it 'enables the feature for the given user when passed user=username' do
post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'conditional',
......@@ -264,7 +264,7 @@ describe API::Features do
post api("/features/#{feature_name}", admin), params: { value: 'false' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'off',
......@@ -277,7 +277,7 @@ describe API::Features do
post api("/features/#{feature_name}", admin), params: { value: 'false', feature_group: 'perf_team' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'off',
......@@ -290,7 +290,7 @@ describe API::Features do
post api("/features/#{feature_name}", admin), params: { value: 'false', user: user.username }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'off',
......@@ -306,7 +306,7 @@ describe API::Features do
it 'updates the percentage of time if passed an integer' do
post api("/features/#{feature_name}", admin), params: { value: '30' }
expect(response).to have_gitlab_http_status(201)
expect(response).to have_gitlab_http_status(:created)
expect(json_response).to eq(
'name' => 'my_feature',
'state' => 'conditional',
......@@ -326,13 +326,13 @@ describe API::Features do
it 'returns a 401 for anonymous users' do
delete api("/features/#{feature_name}")
expect(response).to have_gitlab_http_status(401)
expect(response).to have_gitlab_http_status(:unauthorized)
end
it 'returns a 403 for users' do
delete api("/features/#{feature_name}", user)
expect(response).to have_gitlab_http_status(403)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
......@@ -340,7 +340,7 @@ describe API::Features do
it 'returns 204 when the value is not set' do
delete api("/features/#{feature_name}", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
end
context 'when the gate value was set' do
......@@ -351,7 +351,7 @@ describe API::Features do
it 'deletes an enabled feature' do
delete api("/features/#{feature_name}", admin)
expect(response).to have_gitlab_http_status(204)
expect(response).to have_gitlab_http_status(:no_content)
expect(Feature.get(feature_name)).not_to be_enabled
end
end
......
This diff is collapsed.
......@@ -98,6 +98,53 @@ describe Issues::CloseService do
expect(body_text).not_to include(closing_merge_request.to_reference)
end
end
context 'updating `metrics.first_mentioned_in_commit_at`' do
subject { described_class.new(project, user).close_issue(issue, closed_via: closing_merge_request) }
context 'when `metrics.first_mentioned_in_commit_at` is not set' do
it 'uses the first commit timestamp' do
expected = closing_merge_request.commits.first.date
subject
expect(issue.metrics.first_mentioned_in_commit_at).to eq(expected)
end
end
context 'when `metrics.first_mentioned_in_commit_at` is already set' do
before do
issue.metrics.update!(first_mentioned_in_commit_at: Time.now)
end
it 'does not update the metrics' do
expect { subject }.not_to change { issue.metrics.first_mentioned_in_commit_at }
end
end
context 'when merge request has no commits' do
let(:closing_merge_request) { create(:merge_request, :without_diffs, source_project: project) }
it 'does not update the metrics' do
subject
expect(issue.metrics.first_mentioned_in_commit_at).to be_nil
end
end
context 'when `store_first_mentioned_in_commit_on_issue_close` feature flag is off' do
before do
stub_feature_flags(store_first_mentioned_in_commit_on_issue_close: { enabled: false, thing: issue.project })
end
it 'does not update the metrics' do
subject
expect(described_class).not_to receive(:store_first_mentioned_in_commit_at)
expect(issue.metrics.first_mentioned_in_commit_at).to be_nil
end
end
end
end
context "closed by a commit", :sidekiq_might_not_need_inline do
......
......@@ -118,7 +118,7 @@ describe MergeRequests::MergeService do
it 'closes GitLab issue tracker issues' do
issue = create :issue, project: project
commit = double('commit', safe_message: "Fixes #{issue.to_reference}")
commit = double('commit', safe_message: "Fixes #{issue.to_reference}", date: Time.now)
allow(merge_request).to receive(:commits).and_return([commit])
merge_request.cache_merge_request_closes_issues!
......
......@@ -25,7 +25,31 @@ describe Projects::Alerting::NotifyService do
end
end
shared_examples 'does not process incident issues' do |http_status:|
shared_examples 'sends notification email' do
let(:notification_service) { spy }
it 'sends a notification for firing alerts only' do
expect(NotificationService)
.to receive(:new)
.and_return(notification_service)
expect(notification_service)
.to receive_message_chain(:async, :prometheus_alerts_fired)
expect(subject.status).to eq(:success)
end
end
shared_examples 'does not process incident issues' do
it 'does not process issues' do
expect(IncidentManagement::ProcessAlertWorker)
.not_to receive(:perform_async)
expect(subject.status).to eq(:success)
end
end
shared_examples 'does not process incident issues due to error' do |http_status:|
it 'does not process issues' do
expect(IncidentManagement::ProcessAlertWorker)
.not_to receive(:perform_async)
......@@ -54,31 +78,50 @@ describe Projects::Alerting::NotifyService do
context 'with valid token' do
let(:token) { alerts_service.token }
let(:incident_management_setting) { double(send_email?: email_enabled, create_issue?: issue_enabled) }
let(:email_enabled) { false }
let(:issue_enabled) { false }
before do
allow(service)
.to receive(:incident_management_setting)
.and_return(incident_management_setting)
end
it_behaves_like 'does not process incident issues'
context 'issue enabled' do
let(:issue_enabled) { true }
context 'with a valid payload' do
it_behaves_like 'processes incident issues', 1
end
context 'with an invalid payload' do
before do
allow(Gitlab::Alerting::NotificationPayloadParser)
.to receive(:call)
.and_raise(Gitlab::Alerting::NotificationPayloadParser::BadPayloadError)
context 'with an invalid payload' do
before do
allow(Gitlab::Alerting::NotificationPayloadParser)
.to receive(:call)
.and_raise(Gitlab::Alerting::NotificationPayloadParser::BadPayloadError)
end
it_behaves_like 'does not process incident issues due to error', http_status: 400
end
end
context 'with emails turned on' do
let(:email_enabled) { true }
it_behaves_like 'does not process incident issues', http_status: 400
it_behaves_like 'sends notification email'
end
end
context 'with invalid token' do
it_behaves_like 'does not process incident issues', http_status: 401
it_behaves_like 'does not process incident issues due to error', http_status: 401
end
end
context 'with deactivated Alerts Service' do
let!(:alerts_service) { create(:alerts_service, :inactive, project: project) }
context 'with deactivated Alerts Service' do
let!(:alerts_service) { create(:alerts_service, :inactive, project: project) }
it_behaves_like 'does not process incident issues', http_status: 403
it_behaves_like 'does not process incident issues due to error', http_status: 403
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