summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-08 15:08:01 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-08 15:08:01 +0000
commita7df1d8717d39424ced032d9fe063f08f97e19d6 (patch)
treef887841557b509e950475176baa4d405bfd411f4 /spec/lib
parente3e300557f5def9bf2271735c8a620e6820dfada (diff)
downloadgitlab-ce-a7df1d8717d39424ced032d9fe063f08f97e19d6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/config/entry/reports_spec.rb1
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb42
2 files changed, 43 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/reports_spec.rb b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
index 3c352c30e55..060fc5c1fe0 100644
--- a/spec/lib/gitlab/ci/config/entry/reports_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
@@ -41,6 +41,7 @@ describe Gitlab::Ci::Config::Entry::Reports do
:container_scanning | 'gl-container-scanning-report.json'
:dast | 'gl-dast-report.json'
:license_management | 'gl-license-management-report.json'
+ :license_scanning | 'gl-license-management-report.json'
:performance | 'performance.json'
end
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index 9c8d53b0ed7..439f1343514 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -347,6 +347,48 @@ describe Gitlab::Database::MigrationHelpers do
end
end
+ describe '#validate_foreign_key' do
+ context 'when name is provided' do
+ it 'does not infer the foreign key constraint name' do
+ expect(model).to receive(:foreign_key_exists?).with(:projects, name: :foo).and_return(true)
+
+ aggregate_failures do
+ expect(model).not_to receive(:concurrent_foreign_key_name)
+ expect(model).to receive(:disable_statement_timeout).and_call_original
+ expect(model).to receive(:execute).with(/statement_timeout/)
+ expect(model).to receive(:execute).ordered.with(/ALTER TABLE projects VALIDATE CONSTRAINT/)
+ expect(model).to receive(:execute).ordered.with(/RESET ALL/)
+ end
+
+ model.validate_foreign_key(:projects, :user_id, name: :foo)
+ end
+ end
+
+ context 'when name is not provided' do
+ it 'infers the foreign key constraint name' do
+ expect(model).to receive(:foreign_key_exists?).with(:projects, name: anything).and_return(true)
+
+ aggregate_failures do
+ expect(model).to receive(:concurrent_foreign_key_name)
+ expect(model).to receive(:disable_statement_timeout).and_call_original
+ expect(model).to receive(:execute).with(/statement_timeout/)
+ expect(model).to receive(:execute).ordered.with(/ALTER TABLE projects VALIDATE CONSTRAINT/)
+ expect(model).to receive(:execute).ordered.with(/RESET ALL/)
+ end
+
+ model.validate_foreign_key(:projects, :user_id)
+ end
+
+ context 'when the inferred foreign key constraint does not exist' do
+ it 'raises an error' do
+ expect(model).to receive(:foreign_key_exists?).and_return(false)
+
+ expect { model.validate_foreign_key(:projects, :user_id) }.to raise_error(/cannot find/)
+ end
+ end
+ end
+ end
+
describe '#concurrent_foreign_key_name' do
it 'returns the name for a foreign key' do
name = model.concurrent_foreign_key_name(:this_is_a_very_long_table_name,