Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-22 18:09:49 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-22 18:09:49 +0300
commitf2dfd9ee819afb07bf11bd36a5f9d23009be0d39 (patch)
treeedd9468dc9c6c55f9882175fd83a1aadec22edf0 /spec/lib
parent058c34839488502fcec48d805b83728f928a318c (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/danger/helper_spec.rb1
-rw-r--r--spec/lib/gitlab/database/schema_cleaner_spec.rb31
2 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/lib/gitlab/danger/helper_spec.rb
index 1c9df641655..4cb957f378c 100644
--- a/spec/lib/gitlab/danger/helper_spec.rb
+++ b/spec/lib/gitlab/danger/helper_spec.rb
@@ -229,6 +229,7 @@ describe Gitlab::Danger::Helper do
'ee/FOO_VERSION' | :unknown
'db/schema.rb' | :database
+ 'db/structure.sql' | :database
'db/migrate/foo' | :database
'db/post_migrate/foo' | :database
'ee/db/migrate/foo' | :database
diff --git a/spec/lib/gitlab/database/schema_cleaner_spec.rb b/spec/lib/gitlab/database/schema_cleaner_spec.rb
new file mode 100644
index 00000000000..ee9477156fb
--- /dev/null
+++ b/spec/lib/gitlab/database/schema_cleaner_spec.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe Gitlab::Database::SchemaCleaner do
+ let(:example_schema) { fixture_file(File.join('gitlab', 'database', 'structure_example.sql')) }
+ let(:io) { StringIO.new }
+
+ subject do
+ described_class.new(example_schema).clean(io)
+ io.string
+ end
+
+ it 'removes comments on extensions' do
+ expect(subject).not_to include('COMMENT ON EXTENSION')
+ end
+
+ it 'includes the plpgsql extension' do
+ expect(subject).to include('CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;')
+ end
+
+ it 'sets the search_path' do
+ expect(subject.split("\n").first).to eq('SET search_path=public;')
+ end
+
+ it 'cleans up the full schema as expected (blackbox test with example)' do
+ expected_schema = fixture_file(File.join('gitlab', 'database', 'structure_example_cleaned.sql'))
+
+ expect(subject).to eq(expected_schema)
+ end
+end