Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
e8ba11c538
commit
e4a87ec22d
2 changed files with 59 additions and 17 deletions
|
@ -1,7 +1,7 @@
|
|||
- if @user.note.present?
|
||||
- text = @user.note
|
||||
.card
|
||||
.card-header
|
||||
= render Pajamas::CardComponent.new(card_options: { class: 'gl-mb-5' }, body_options: { class: 'gl-pb-0'}) do |c|
|
||||
- c.header do
|
||||
= _('Admin Note')
|
||||
.card-body
|
||||
- c.body do
|
||||
%p= text
|
||||
|
|
|
@ -9,6 +9,7 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
describe 'GET /admin/batched_background_migrations/:id' do
|
||||
let!(:migration) { create(:batched_background_migration, :paused) }
|
||||
let(:database) { :main }
|
||||
let(:params) { { database: database } }
|
||||
|
||||
subject(:show_migration) do
|
||||
get api("/admin/batched_background_migrations/#{migration.id}", admin), params: { database: database }
|
||||
|
@ -27,10 +28,8 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
end
|
||||
|
||||
context 'when the batched background migration does not exist' do
|
||||
let(:params) { { database: database } }
|
||||
|
||||
it 'returns 404' do
|
||||
put api("/admin/batched_background_migrations/#{non_existing_record_id}", admin), params: params
|
||||
get api("/admin/batched_background_migrations/#{non_existing_record_id}", admin), params: params
|
||||
|
||||
expect(response).to have_gitlab_http_status(:not_found)
|
||||
end
|
||||
|
@ -58,6 +57,17 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
expect(response).to have_gitlab_http_status(:forbidden)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the database name does not exist' do
|
||||
let(:database) { :wrong_database }
|
||||
|
||||
it 'returns bad request' do
|
||||
get api("/admin/batched_background_migrations/#{migration.id}", admin), params: params
|
||||
|
||||
expect(response).to have_gitlab_http_status(:bad_request)
|
||||
expect(response.body).to include('database does not have a valid value')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET /admin/batched_background_migrations' do
|
||||
|
@ -82,6 +92,7 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
let(:database) { :ci }
|
||||
let(:schema) { :gitlab_ci }
|
||||
let(:ci_model) { Ci::ApplicationRecord }
|
||||
let(:params) { { database: database } }
|
||||
|
||||
context 'when CI database is provided' do
|
||||
let(:db_config) { instance_double(ActiveRecord::DatabaseConfigurations::HashConfig, name: 'fake_db') }
|
||||
|
@ -94,7 +105,18 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
|
||||
expect(Gitlab::Database::SharedModel).to receive(:using_connection).with(ci_model.connection).and_yield
|
||||
|
||||
get api('/admin/batched_background_migrations', admin), params: { database: :ci }
|
||||
get api('/admin/batched_background_migrations', admin), params: params
|
||||
end
|
||||
|
||||
context 'when the database name does not exist' do
|
||||
let(:database) { :wrong_database }
|
||||
|
||||
it 'returns bad request' do
|
||||
get api("/admin/batched_background_migrations", admin), params: params
|
||||
|
||||
expect(response).to have_gitlab_http_status(:bad_request)
|
||||
expect(response.body).to include('database does not have a valid value')
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns CI database records' do
|
||||
|
@ -105,7 +127,7 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
create(:batched_background_migration, :active, gitlab_schema: schema)
|
||||
end
|
||||
|
||||
get api('/admin/batched_background_migrations', admin), params: { database: :ci }
|
||||
get api('/admin/batched_background_migrations', admin), params: params
|
||||
|
||||
aggregate_failures "testing response" do
|
||||
expect(response).to have_gitlab_http_status(:ok)
|
||||
|
@ -133,9 +155,10 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
describe 'PUT /admin/batched_background_migrations/:id/resume' do
|
||||
let!(:migration) { create(:batched_background_migration, :paused) }
|
||||
let(:database) { :main }
|
||||
let(:params) { { database: database } }
|
||||
|
||||
subject(:resume) do
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/resume", admin), params: { database: database }
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/resume", admin), params: params
|
||||
end
|
||||
|
||||
it 'pauses the batched background migration' do
|
||||
|
@ -149,8 +172,6 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
end
|
||||
|
||||
context 'when the batched background migration does not exist' do
|
||||
let(:params) { { database: database } }
|
||||
|
||||
it 'returns 404' do
|
||||
put api("/admin/batched_background_migrations/#{non_existing_record_id}/resume", admin), params: params
|
||||
|
||||
|
@ -160,7 +181,6 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
|
||||
context 'when the migration is not paused' do
|
||||
let!(:migration) { create(:batched_background_migration, :failed) }
|
||||
let(:params) { { database: database } }
|
||||
|
||||
it 'returns 422' do
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/resume", admin), params: params
|
||||
|
@ -182,6 +202,17 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
|
||||
resume
|
||||
end
|
||||
|
||||
context 'when the database name does not exist' do
|
||||
let(:database) { :wrong_database }
|
||||
|
||||
it 'returns bad request' do
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/resume", admin), params: params
|
||||
|
||||
expect(response).to have_gitlab_http_status(:bad_request)
|
||||
expect(response.body).to include('database does not have a valid value')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when authenticated as a non-admin user' do
|
||||
|
@ -195,9 +226,11 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
|
||||
describe 'PUT /admin/batched_background_migrations/:id/pause' do
|
||||
let!(:migration) { create(:batched_background_migration, :active) }
|
||||
let(:database) { :main }
|
||||
let(:params) { { database: database } }
|
||||
|
||||
it 'pauses the batched background migration' do
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/pause", admin), params: { database: :main }
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/pause", admin), params: params
|
||||
|
||||
aggregate_failures "testing response" do
|
||||
expect(response).to have_gitlab_http_status(:ok)
|
||||
|
@ -207,8 +240,6 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
end
|
||||
|
||||
context 'when the batched background migration does not exist' do
|
||||
let(:params) { { database: :main } }
|
||||
|
||||
it 'returns 404' do
|
||||
put api("/admin/batched_background_migrations/#{non_existing_record_id}/pause", admin), params: params
|
||||
|
||||
|
@ -218,7 +249,6 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
|
||||
context 'when the migration is not active' do
|
||||
let!(:migration) { create(:batched_background_migration, :failed) }
|
||||
let(:params) { { database: :main } }
|
||||
|
||||
it 'returns 422' do
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/pause", admin), params: params
|
||||
|
@ -229,6 +259,7 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
|
||||
context 'when multiple database is enabled' do
|
||||
let(:ci_model) { Ci::ApplicationRecord }
|
||||
let(:database) { :ci }
|
||||
|
||||
before do
|
||||
skip_if_multiple_databases_not_setup
|
||||
|
@ -237,7 +268,18 @@ RSpec.describe API::Admin::BatchedBackgroundMigrations do
|
|||
it 'uses the correct connection' do
|
||||
expect(Gitlab::Database::SharedModel).to receive(:using_connection).with(ci_model.connection).and_yield
|
||||
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/pause", admin), params: { database: :ci }
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/pause", admin), params: params
|
||||
end
|
||||
|
||||
context 'when the database name does not exist' do
|
||||
let(:database) { :wrong_database }
|
||||
|
||||
it 'returns bad request' do
|
||||
put api("/admin/batched_background_migrations/#{migration.id}/pause", admin), params: params
|
||||
|
||||
expect(response).to have_gitlab_http_status(:bad_request)
|
||||
expect(response.body).to include('database does not have a valid value')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue