diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-14 13:26:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-14 13:26:13 +0300 |
commit | 4588bbc93a7857eb2d031a4f3e0212c0aa46b846 (patch) | |
tree | 1c1c9795491b5e6a97a5e8b5f00e4e2dcc99e5a1 /spec/lib/gitlab | |
parent | 8236147d0fcb9f4f8c315f895aebc0c8158e2f7d (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/lib/gitlab')
-rw-r--r-- | spec/lib/gitlab/database/migration_helpers_spec.rb | 52 |
1 files changed, 52 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 |