Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
6f0f893bd8
commit
667f6fbc8d
|
@ -101,6 +101,13 @@ ul.unstyled-list > li {
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul.list-items-py-2 {
|
||||||
|
> li {
|
||||||
|
padding-top: 0.5rem;
|
||||||
|
padding-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Generic content list
|
// Generic content list
|
||||||
ul.content-list {
|
ul.content-list {
|
||||||
@include basic-list;
|
@include basic-list;
|
||||||
|
|
|
@ -290,6 +290,8 @@
|
||||||
|
|
||||||
= render_if_exists 'layouts/nav/sidebar/project_packages_link'
|
= render_if_exists 'layouts/nav/sidebar/project_packages_link'
|
||||||
|
|
||||||
|
= render_if_exists 'layouts/nav/sidebar/project_analytics_link' # EE-specific
|
||||||
|
|
||||||
- if project_nav_tab? :wiki
|
- if project_nav_tab? :wiki
|
||||||
- wiki_url = project_wiki_path(@project, :home)
|
- wiki_url = project_wiki_path(@project, :home)
|
||||||
= nav_link(controller: :wikis) do
|
= nav_link(controller: :wikis) do
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Make BackgroundMigrationWorker backward compatible
|
||||||
|
merge_request: 22271
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -136,6 +136,9 @@ using environment variables.
|
||||||
| `DS_PYTHON_VERSION` | Version of Python. If set to 2, dependencies are installed using Python 2.7 instead of Python 3.6. ([Introduced](https://gitlab.com/gitlab-org/gitlab/issues/12296) in GitLab 12.1)|
|
| `DS_PYTHON_VERSION` | Version of Python. If set to 2, dependencies are installed using Python 2.7 instead of Python 3.6. ([Introduced](https://gitlab.com/gitlab-org/gitlab/issues/12296) in GitLab 12.1)|
|
||||||
| `DS_PIP_VERSION` | Force the install of a specific pip version (example: `"19.3"`), otherwise the pip installed in the docker image is used. |
|
| `DS_PIP_VERSION` | Force the install of a specific pip version (example: `"19.3"`), otherwise the pip installed in the docker image is used. |
|
||||||
| `DS_PIP_DEPENDENCY_PATH` | Path to load Python pip dependencies from. ([Introduced](https://gitlab.com/gitlab-org/gitlab/issues/12412) in GitLab 12.2) |
|
| `DS_PIP_DEPENDENCY_PATH` | Path to load Python pip dependencies from. ([Introduced](https://gitlab.com/gitlab-org/gitlab/issues/12412) in GitLab 12.2) |
|
||||||
|
| `GEMNASIUM_DB_LOCAL_PATH` | Path to local gemnasium database (default `/gemnasium-db`).
|
||||||
|
| `GEMNASIUM_DB_REMOTE_URL` | Repository URL for fetching the gemnasium database (default `https://gitlab.com/gitlab-org/security-products/gemnasium-db.git`).
|
||||||
|
| `GEMNASIUM_DB_REF_NAME` | Branch name for remote repository database (default `master`). `GEMNASIUM_DB_REMOTE_URL` is required.
|
||||||
| `DS_DEFAULT_ANALYZERS` | Override the names of the official default images. Read more about [customizing analyzers](analyzers.md). |
|
| `DS_DEFAULT_ANALYZERS` | Override the names of the official default images. Read more about [customizing analyzers](analyzers.md). |
|
||||||
| `DS_DISABLE_DIND` | Disable Docker in Docker and run analyzers [individually](#disabling-docker-in-docker-for-dependency-scanning).|
|
| `DS_DISABLE_DIND` | Disable Docker in Docker and run analyzers [individually](#disabling-docker-in-docker-for-dependency-scanning).|
|
||||||
| `DS_PULL_ANALYZER_IMAGES` | Pull the images from the Docker registry (set to `0` to disable). |
|
| `DS_PULL_ANALYZER_IMAGES` | Pull the images from the Docker registry (set to `0` to disable). |
|
||||||
|
|
|
@ -78,6 +78,20 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.migration_class_for(class_name)
|
def self.migration_class_for(class_name)
|
||||||
|
# We don't pass class name with Gitlab::BackgroundMigration:: prefix anymore
|
||||||
|
# but some jobs could be already spawned so we need to have some backward compatibility period.
|
||||||
|
# Can be removed since 13.x
|
||||||
|
full_class_name_prefix_regexp = /\A(::)?Gitlab::BackgroundMigration::/
|
||||||
|
|
||||||
|
if class_name.match(full_class_name_prefix_regexp)
|
||||||
|
Gitlab::ErrorTracking.track_and_raise_for_dev_exception(
|
||||||
|
StandardError.new("Full class name is used"),
|
||||||
|
class_name: class_name
|
||||||
|
)
|
||||||
|
|
||||||
|
class_name = class_name.sub(full_class_name_prefix_regexp, '')
|
||||||
|
end
|
||||||
|
|
||||||
const_get(class_name, false)
|
const_get(class_name, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4514,6 +4514,9 @@ msgstr ""
|
||||||
msgid "Code Owners to the merge request changes."
|
msgid "Code Owners to the merge request changes."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Code Review"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Code owner approval is required"
|
msgid "Code owner approval is required"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -13905,6 +13908,9 @@ msgstr ""
|
||||||
msgid "Project '%{project_name}' will be deleted on %{date}"
|
msgid "Project '%{project_name}' will be deleted on %{date}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Project Analytics"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Project Badges"
|
msgid "Project Badges"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -15568,6 +15574,9 @@ msgstr ""
|
||||||
msgid "Review the process for configuring service providers in your identity provider — in this case, GitLab is the \"service provider\" or \"relying party\"."
|
msgid "Review the process for configuring service providers in your identity provider — in this case, GitLab is the \"service provider\" or \"relying party\"."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Review time is defined as the time it takes from first comment until merged."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
msgid "Reviewing"
|
msgid "Reviewing"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||||
|
import Vuex from 'vuex';
|
||||||
|
import createState from '~/create_cluster/gke_cluster/store/state';
|
||||||
|
import { selectedProjectMock, gapiProjectsResponseMock } from '../mock_data';
|
||||||
|
import GkeProjectIdDropdown from '~/create_cluster/gke_cluster/components/gke_project_id_dropdown.vue';
|
||||||
|
import DropdownButton from '~/vue_shared/components/dropdown/dropdown_button.vue';
|
||||||
|
import DropdownHiddenInput from '~/vue_shared/components/dropdown/dropdown_hidden_input.vue';
|
||||||
|
|
||||||
|
const componentConfig = {
|
||||||
|
docsUrl: 'https://console.cloud.google.com/home/dashboard',
|
||||||
|
fieldId: 'cluster_provider_gcp_attributes_gcp_project_id',
|
||||||
|
fieldName: 'cluster[provider_gcp_attributes][gcp_project_id]',
|
||||||
|
};
|
||||||
|
|
||||||
|
const LABELS = {
|
||||||
|
LOADING: 'Fetching projects',
|
||||||
|
VALIDATING_PROJECT_BILLING: 'Validating project billing status',
|
||||||
|
DEFAULT: 'Select project',
|
||||||
|
EMPTY: 'No projects found',
|
||||||
|
};
|
||||||
|
|
||||||
|
const localVue = createLocalVue();
|
||||||
|
|
||||||
|
localVue.use(Vuex);
|
||||||
|
|
||||||
|
describe('GkeProjectIdDropdown', () => {
|
||||||
|
let wrapper;
|
||||||
|
let vuexStore;
|
||||||
|
let setProject;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
setProject = jest.fn();
|
||||||
|
});
|
||||||
|
|
||||||
|
const createStore = (initialState = {}, getters = {}) =>
|
||||||
|
new Vuex.Store({
|
||||||
|
state: {
|
||||||
|
...createState(),
|
||||||
|
...initialState,
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
fetchProjects: jest.fn().mockResolvedValueOnce([]),
|
||||||
|
setProject,
|
||||||
|
},
|
||||||
|
getters: {
|
||||||
|
hasProject: () => false,
|
||||||
|
...getters,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const createComponent = (store, propsData = componentConfig) =>
|
||||||
|
shallowMount(GkeProjectIdDropdown, {
|
||||||
|
propsData,
|
||||||
|
store,
|
||||||
|
localVue,
|
||||||
|
});
|
||||||
|
|
||||||
|
const bootstrap = (initialState, getters) => {
|
||||||
|
vuexStore = createStore(initialState, getters);
|
||||||
|
wrapper = createComponent(vuexStore);
|
||||||
|
};
|
||||||
|
|
||||||
|
const dropdownButtonLabel = () => wrapper.find(DropdownButton).props('toggleText');
|
||||||
|
const dropdownHiddenInputValue = () => wrapper.find(DropdownHiddenInput).props('value');
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
wrapper.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('toggleText', () => {
|
||||||
|
it('returns loading toggle text', () => {
|
||||||
|
bootstrap();
|
||||||
|
|
||||||
|
expect(dropdownButtonLabel()).toBe(LABELS.LOADING);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns project billing validation text', () => {
|
||||||
|
bootstrap({ isValidatingProjectBilling: true });
|
||||||
|
|
||||||
|
expect(dropdownButtonLabel()).toBe(LABELS.VALIDATING_PROJECT_BILLING);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns default toggle text', () => {
|
||||||
|
bootstrap();
|
||||||
|
|
||||||
|
wrapper.setData({ isLoading: false });
|
||||||
|
|
||||||
|
return wrapper.vm.$nextTick().then(() => {
|
||||||
|
expect(dropdownButtonLabel()).toBe(LABELS.DEFAULT);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns project name if project selected', () => {
|
||||||
|
bootstrap(
|
||||||
|
{
|
||||||
|
selectedProject: selectedProjectMock,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
hasProject: () => true,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
wrapper.setData({ isLoading: false });
|
||||||
|
|
||||||
|
return wrapper.vm.$nextTick().then(() => {
|
||||||
|
expect(dropdownButtonLabel()).toBe(selectedProjectMock.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns empty toggle text', () => {
|
||||||
|
bootstrap({
|
||||||
|
projects: null,
|
||||||
|
});
|
||||||
|
wrapper.setData({ isLoading: false });
|
||||||
|
|
||||||
|
return wrapper.vm.$nextTick().then(() => {
|
||||||
|
expect(dropdownButtonLabel()).toBe(LABELS.EMPTY);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('selectItem', () => {
|
||||||
|
it('reflects new value when dropdown item is clicked', () => {
|
||||||
|
bootstrap({ projects: gapiProjectsResponseMock.projects });
|
||||||
|
|
||||||
|
expect(dropdownHiddenInputValue()).toBe('');
|
||||||
|
|
||||||
|
wrapper.find('.dropdown-content button').trigger('click');
|
||||||
|
|
||||||
|
return wrapper.vm.$nextTick().then(() => {
|
||||||
|
expect(setProject).toHaveBeenCalledWith(
|
||||||
|
expect.anything(),
|
||||||
|
gapiProjectsResponseMock.projects[0],
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,115 +0,0 @@
|
||||||
import Vue from 'vue';
|
|
||||||
import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper';
|
|
||||||
import GkeProjectIdDropdown from '~/create_cluster/gke_cluster/components/gke_project_id_dropdown.vue';
|
|
||||||
import { createStore } from '~/create_cluster/gke_cluster/store';
|
|
||||||
import { SET_PROJECTS } from '~/create_cluster/gke_cluster/store/mutation_types';
|
|
||||||
import { emptyProjectMock, selectedProjectMock } from '../mock_data';
|
|
||||||
import { gapi } from '../helpers';
|
|
||||||
|
|
||||||
const componentConfig = {
|
|
||||||
docsUrl: 'https://console.cloud.google.com/home/dashboard',
|
|
||||||
fieldId: 'cluster_provider_gcp_attributes_gcp_project_id',
|
|
||||||
fieldName: 'cluster[provider_gcp_attributes][gcp_project_id]',
|
|
||||||
};
|
|
||||||
|
|
||||||
const LABELS = {
|
|
||||||
LOADING: 'Fetching projects',
|
|
||||||
VALIDATING_PROJECT_BILLING: 'Validating project billing status',
|
|
||||||
DEFAULT: 'Select project',
|
|
||||||
EMPTY: 'No projects found',
|
|
||||||
};
|
|
||||||
|
|
||||||
const createComponent = (store, props = componentConfig) => {
|
|
||||||
const Component = Vue.extend(GkeProjectIdDropdown);
|
|
||||||
|
|
||||||
return mountComponentWithStore(Component, {
|
|
||||||
el: null,
|
|
||||||
props,
|
|
||||||
store,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('GkeProjectIdDropdown', () => {
|
|
||||||
let vm;
|
|
||||||
let store;
|
|
||||||
|
|
||||||
let originalGapi;
|
|
||||||
beforeAll(() => {
|
|
||||||
originalGapi = window.gapi;
|
|
||||||
window.gapi = gapi();
|
|
||||||
});
|
|
||||||
|
|
||||||
afterAll(() => {
|
|
||||||
window.gapi = originalGapi;
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
store = createStore();
|
|
||||||
vm = createComponent(store);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
vm.$destroy();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('toggleText', () => {
|
|
||||||
it('returns loading toggle text', () => {
|
|
||||||
expect(vm.toggleText).toBe(LABELS.LOADING);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns project billing validation text', () => {
|
|
||||||
vm.setIsValidatingProjectBilling(true);
|
|
||||||
|
|
||||||
expect(vm.toggleText).toBe(LABELS.VALIDATING_PROJECT_BILLING);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns default toggle text', done =>
|
|
||||||
setTimeout(() => {
|
|
||||||
vm.setItem(emptyProjectMock);
|
|
||||||
|
|
||||||
expect(vm.toggleText).toBe(LABELS.DEFAULT);
|
|
||||||
|
|
||||||
done();
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('returns project name if project selected', done =>
|
|
||||||
setTimeout(() => {
|
|
||||||
vm.isLoading = false;
|
|
||||||
|
|
||||||
expect(vm.toggleText).toBe(selectedProjectMock.name);
|
|
||||||
|
|
||||||
done();
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('returns empty toggle text', done =>
|
|
||||||
setTimeout(() => {
|
|
||||||
vm.$store.commit(SET_PROJECTS, null);
|
|
||||||
vm.setItem(emptyProjectMock);
|
|
||||||
|
|
||||||
expect(vm.toggleText).toBe(LABELS.EMPTY);
|
|
||||||
|
|
||||||
done();
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('selectItem', () => {
|
|
||||||
it('reflects new value when dropdown item is clicked', done => {
|
|
||||||
expect(vm.$el.querySelector('input').value).toBe('');
|
|
||||||
|
|
||||||
return vm
|
|
||||||
.$nextTick()
|
|
||||||
.then(() => {
|
|
||||||
vm.$el.querySelector('.dropdown-content button').click();
|
|
||||||
|
|
||||||
return vm
|
|
||||||
.$nextTick()
|
|
||||||
.then(() => {
|
|
||||||
expect(vm.$el.querySelector('input').value).toBe(selectedProjectMock.projectId);
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
.catch(done.fail);
|
|
||||||
})
|
|
||||||
.catch(done.fail);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -152,6 +152,17 @@ describe Gitlab::BackgroundMigration do
|
||||||
|
|
||||||
described_class.perform('Foo', [10, 20])
|
described_class.perform('Foo', [10, 20])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'backward compatibility' do
|
||||||
|
it 'performs a background migration for fully-qualified job classes' do
|
||||||
|
expect(migration).to receive(:perform).with(10, 20).once
|
||||||
|
expect(Gitlab::ErrorTracking)
|
||||||
|
.to receive(:track_and_raise_for_dev_exception)
|
||||||
|
.with(instance_of(StandardError), hash_including(:class_name))
|
||||||
|
|
||||||
|
described_class.perform('Gitlab::BackgroundMigration::Foo', [10, 20])
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.exists?' do
|
describe '.exists?' do
|
||||||
|
|
|
@ -22,44 +22,9 @@ describe 'Self-Monitoring project requests' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with feature flag enabled' do
|
context 'with feature flag enabled' do
|
||||||
it 'returns sidekiq job_id of expected length' do
|
let(:status_api) { status_create_self_monitoring_project_admin_application_settings_path }
|
||||||
subject
|
|
||||||
|
|
||||||
job_id = json_response['job_id']
|
it_behaves_like 'triggers async worker, returns sidekiq job_id with response accepted'
|
||||||
|
|
||||||
aggregate_failures do
|
|
||||||
expect(job_id).to be_present
|
|
||||||
expect(job_id.length).to be <= Admin::ApplicationSettingsController::PARAM_JOB_ID_MAX_SIZE
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'triggers async worker' do
|
|
||||||
expect(worker_class).to receive(:perform_async)
|
|
||||||
|
|
||||||
subject
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns accepted response' do
|
|
||||||
subject
|
|
||||||
|
|
||||||
aggregate_failures do
|
|
||||||
expect(response).to have_gitlab_http_status(:accepted)
|
|
||||||
expect(json_response.keys).to contain_exactly('job_id', 'monitor_status')
|
|
||||||
expect(json_response).to include(
|
|
||||||
'monitor_status' => status_create_self_monitoring_project_admin_application_settings_path
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns job_id' do
|
|
||||||
fake_job_id = 'b5b28910d97563e58c2fe55f'
|
|
||||||
expect(worker_class).to receive(:perform_async).and_return(fake_job_id)
|
|
||||||
|
|
||||||
subject
|
|
||||||
response_job_id = json_response['job_id']
|
|
||||||
|
|
||||||
expect(response_job_id).to eq fake_job_id
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -85,15 +50,32 @@ describe 'Self-Monitoring project requests' do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with feature flag enabled' do
|
context 'with feature flag enabled' do
|
||||||
context 'with invalid job_id' do
|
it_behaves_like 'handles invalid job_id'
|
||||||
it 'returns bad_request if job_id too long' do
|
|
||||||
get status_create_self_monitoring_project_admin_application_settings_path,
|
context 'when job is in progress' do
|
||||||
params: { job_id: 'a' * 51 }
|
before do
|
||||||
|
allow(worker_class).to receive(:in_progress?)
|
||||||
|
.with(job_id)
|
||||||
|
.and_return(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like 'sets polling header and returns accepted' do
|
||||||
|
let(:in_progress_message) { 'Job is in progress' }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when self-monitoring project and job do not exist' do
|
||||||
|
let(:job_id) { nil }
|
||||||
|
|
||||||
|
it 'returns bad_request' do
|
||||||
|
subject
|
||||||
|
|
||||||
aggregate_failures do
|
aggregate_failures do
|
||||||
expect(response).to have_gitlab_http_status(:bad_request)
|
expect(response).to have_gitlab_http_status(:bad_request)
|
||||||
expect(json_response).to eq('message' => 'Parameter "job_id" cannot ' \
|
expect(json_response).to eq(
|
||||||
"exceed length of #{Admin::ApplicationSettingsController::PARAM_JOB_ID_MAX_SIZE}")
|
'message' => 'Self-monitoring project does not exist. Please check logs ' \
|
||||||
|
'for any error messages'
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -118,7 +100,7 @@ describe 'Self-Monitoring project requests' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'returns success' do
|
it 'returns success with job_id' do
|
||||||
subject
|
subject
|
||||||
|
|
||||||
aggregate_failures do
|
aggregate_failures do
|
||||||
|
@ -130,45 +112,6 @@ describe 'Self-Monitoring project requests' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when job is in progress' do
|
|
||||||
before do
|
|
||||||
allow(worker_class).to receive(:in_progress?)
|
|
||||||
.with(job_id)
|
|
||||||
.and_return(true)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'sets polling header' do
|
|
||||||
expect(::Gitlab::PollingInterval).to receive(:set_header)
|
|
||||||
|
|
||||||
subject
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns accepted' do
|
|
||||||
subject
|
|
||||||
|
|
||||||
aggregate_failures do
|
|
||||||
expect(response).to have_gitlab_http_status(:accepted)
|
|
||||||
expect(json_response).to eq('message' => 'Job is in progress')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when self-monitoring project and job do not exist' do
|
|
||||||
let(:job_id) { nil }
|
|
||||||
|
|
||||||
it 'returns bad_request' do
|
|
||||||
subject
|
|
||||||
|
|
||||||
aggregate_failures do
|
|
||||||
expect(response).to have_gitlab_http_status(:bad_request)
|
|
||||||
expect(json_response).to eq(
|
|
||||||
'message' => 'Self-monitoring project does not exist. Please check ' \
|
|
||||||
'logs for any error messages'
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,3 +39,94 @@ RSpec.shared_examples 'not accessible to non-admin users' do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Requires subject and worker_class and status_api to be defined
|
||||||
|
# let(:worker_class) { SelfMonitoringProjectCreateWorker }
|
||||||
|
# let(:status_api) { status_create_self_monitoring_project_admin_application_settings_path }
|
||||||
|
# subject { post create_self_monitoring_project_admin_application_settings_path }
|
||||||
|
RSpec.shared_examples 'triggers async worker, returns sidekiq job_id with response accepted' do
|
||||||
|
it 'returns sidekiq job_id of expected length' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
job_id = json_response['job_id']
|
||||||
|
|
||||||
|
aggregate_failures do
|
||||||
|
expect(job_id).to be_present
|
||||||
|
expect(job_id.length).to be <= Admin::ApplicationSettingsController::PARAM_JOB_ID_MAX_SIZE
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'triggers async worker' do
|
||||||
|
expect(worker_class).to receive(:perform_async)
|
||||||
|
|
||||||
|
subject
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns accepted response' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
aggregate_failures do
|
||||||
|
expect(response).to have_gitlab_http_status(:accepted)
|
||||||
|
expect(json_response.keys).to contain_exactly('job_id', 'monitor_status')
|
||||||
|
expect(json_response).to include(
|
||||||
|
'monitor_status' => status_api
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns job_id' do
|
||||||
|
fake_job_id = 'b5b28910d97563e58c2fe55f'
|
||||||
|
allow(worker_class).to receive(:perform_async).and_return(fake_job_id)
|
||||||
|
|
||||||
|
subject
|
||||||
|
|
||||||
|
expect(json_response).to include('job_id' => fake_job_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Requires job_id and subject to be defined
|
||||||
|
# let(:job_id) { 'job_id' }
|
||||||
|
# subject do
|
||||||
|
# get status_create_self_monitoring_project_admin_application_settings_path,
|
||||||
|
# params: { job_id: job_id }
|
||||||
|
# end
|
||||||
|
RSpec.shared_examples 'handles invalid job_id' do
|
||||||
|
context 'with invalid job_id' do
|
||||||
|
let(:job_id) { 'a' * 51 }
|
||||||
|
|
||||||
|
it 'returns bad_request if job_id too long' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
aggregate_failures do
|
||||||
|
expect(response).to have_gitlab_http_status(:bad_request)
|
||||||
|
expect(json_response).to eq('message' => 'Parameter "job_id" cannot ' \
|
||||||
|
"exceed length of #{Admin::ApplicationSettingsController::PARAM_JOB_ID_MAX_SIZE}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Requires in_progress_message and subject to be defined
|
||||||
|
# let(:in_progress_message) { 'Job to create self-monitoring project is in progress' }
|
||||||
|
# subject do
|
||||||
|
# get status_create_self_monitoring_project_admin_application_settings_path,
|
||||||
|
# params: { job_id: job_id }
|
||||||
|
# end
|
||||||
|
RSpec.shared_examples 'sets polling header and returns accepted' do
|
||||||
|
it 'sets polling header' do
|
||||||
|
expect(::Gitlab::PollingInterval).to receive(:set_header)
|
||||||
|
|
||||||
|
subject
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns accepted' do
|
||||||
|
subject
|
||||||
|
|
||||||
|
aggregate_failures do
|
||||||
|
expect(response).to have_gitlab_http_status(:accepted)
|
||||||
|
expect(json_response).to eq(
|
||||||
|
'message' => in_progress_message
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue