diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-14 10:26:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-14 10:26:13 +0000 |
commit | 4588bbc93a7857eb2d031a4f3e0212c0aa46b846 (patch) | |
tree | 1c1c9795491b5e6a97a5e8b5f00e4e2dcc99e5a1 /spec | |
parent | 8236147d0fcb9f4f8c315f895aebc0c8158e2f7d (diff) | |
download | gitlab-ce-4588bbc93a7857eb2d031a4f3e0212c0aa46b846.tar.gz |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/database/migration_helpers_spec.rb | 52 | ||||
-rw-r--r-- | spec/requests/api/conan_packages_spec.rb | 12 |
2 files changed, 64 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb index 4b7f371b25a..7d26fbb1132 100644 --- a/spec/lib/gitlab/database/migration_helpers_spec.rb +++ b/spec/lib/gitlab/database/migration_helpers_spec.rb @@ -2329,4 +2329,56 @@ RSpec.describe Gitlab::Database::MigrationHelpers do end end end + + describe '#create_extension' do + subject { model.create_extension(extension) } + + let(:extension) { :btree_gist } + + it 'executes CREATE EXTENSION statement' do + expect(model).to receive(:execute).with(/CREATE EXTENSION IF NOT EXISTS #{extension}/) + + subject + end + + context 'without proper permissions' do + before do + allow(model).to receive(:execute).with(/CREATE EXTENSION IF NOT EXISTS #{extension}/).and_raise(ActiveRecord::StatementInvalid, 'InsufficientPrivilege: permission denied') + end + + it 'raises the exception' do + expect { subject }.to raise_error(ActiveRecord::StatementInvalid, /InsufficientPrivilege/) + end + + it 'prints an error message' do + expect { subject }.to output(/user is not allowed/).to_stderr.and raise_error + end + end + end + + describe '#drop_extension' do + subject { model.drop_extension(extension) } + + let(:extension) { 'btree_gist' } + + it 'executes CREATE EXTENSION statement' do + expect(model).to receive(:execute).with(/DROP EXTENSION IF EXISTS #{extension}/) + + subject + end + + context 'without proper permissions' do + before do + allow(model).to receive(:execute).with(/DROP EXTENSION IF EXISTS #{extension}/).and_raise(ActiveRecord::StatementInvalid, 'InsufficientPrivilege: permission denied') + end + + it 'raises the exception' do + expect { subject }.to raise_error(ActiveRecord::StatementInvalid, /InsufficientPrivilege/) + end + + it 'prints an error message' do + expect { subject }.to output(/user is not allowed/).to_stderr.and raise_error + end + end + end end diff --git a/spec/requests/api/conan_packages_spec.rb b/spec/requests/api/conan_packages_spec.rb index 7a97743ede1..d24f6b68048 100644 --- a/spec/requests/api/conan_packages_spec.rb +++ b/spec/requests/api/conan_packages_spec.rb @@ -363,6 +363,16 @@ RSpec.describe API::ConanPackages do end end + shared_examples 'successful response when using Unicorn' do + context 'on Unicorn', :unicorn do + it 'returns successfully' do + subject + + expect(response).to have_gitlab_http_status(:ok) + end + end + end + describe 'GET /api/v4/packages/conan/v1/conans/:package_name/package_version/:package_username/:package_channel' do let(:recipe_path) { package.conan_recipe_path } @@ -458,6 +468,7 @@ RSpec.describe API::ConanPackages do it_behaves_like 'rejects invalid recipe' it_behaves_like 'rejects invalid upload_url params' + it_behaves_like 'successful response when using Unicorn' it 'returns a set of upload urls for the files requested' do subject @@ -521,6 +532,7 @@ RSpec.describe API::ConanPackages do it_behaves_like 'rejects invalid recipe' it_behaves_like 'rejects invalid upload_url params' + it_behaves_like 'successful response when using Unicorn' it 'returns a set of upload urls for the files requested' do expected_response = { |