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
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/database/postgres_index_spec.rb')
-rw-r--r--spec/lib/gitlab/database/postgres_index_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/lib/gitlab/database/postgres_index_spec.rb b/spec/lib/gitlab/database/postgres_index_spec.rb
index e1832219ebf..9088719d5a4 100644
--- a/spec/lib/gitlab/database/postgres_index_spec.rb
+++ b/spec/lib/gitlab/database/postgres_index_spec.rb
@@ -40,6 +40,37 @@ RSpec.describe Gitlab::Database::PostgresIndex do
expect(types & %w(btree gist)).to eq(types)
end
+
+ context 'with leftover indexes' do
+ before do
+ ActiveRecord::Base.connection.execute(<<~SQL)
+ CREATE INDEX foobar_ccnew ON users (id);
+ CREATE INDEX foobar_ccnew1 ON users (id);
+ SQL
+ end
+
+ subject { described_class.reindexing_support.map(&:name) }
+
+ it 'excludes temporary indexes from reindexing' do
+ expect(subject).not_to include('foobar_ccnew')
+ expect(subject).not_to include('foobar_ccnew1')
+ end
+ end
+ end
+
+ describe '.reindexing_leftovers' do
+ subject { described_class.reindexing_leftovers }
+
+ before do
+ ActiveRecord::Base.connection.execute(<<~SQL)
+ CREATE INDEX foobar_ccnew ON users (id);
+ CREATE INDEX foobar_ccnew1 ON users (id);
+ SQL
+ end
+
+ it 'retrieves leftover indexes matching the /_ccnew[0-9]*$/ pattern' do
+ expect(subject.map(&:name)).to eq(%w(foobar_ccnew foobar_ccnew1))
+ end
end
describe '.not_match' do