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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-11 21:08:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-11 21:08:28 +0300
commit0cc7fe66f5f614339b6584e66371ef3cd2c9fd97 (patch)
tree6c25bb4ae1f2747e1236bc5b1b4609e7507002b8 /spec/migrations
parent018431c70e62358b959d23e7881bf1513e68f165 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r--spec/migrations/backfill_imported_snippet_repositories_spec.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/migrations/backfill_imported_snippet_repositories_spec.rb b/spec/migrations/backfill_imported_snippet_repositories_spec.rb
new file mode 100644
index 00000000000..c77978b23e4
--- /dev/null
+++ b/spec/migrations/backfill_imported_snippet_repositories_spec.rb
@@ -0,0 +1,52 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20200608072931_backfill_imported_snippet_repositories.rb')
+
+describe BackfillImportedSnippetRepositories do
+ let(:users) { table(:users) }
+ let(:snippets) { table(:snippets) }
+ let(:user) { users.create(id: 1, email: 'user@example.com', projects_limit: 10, username: 'test', name: 'Test', state: 'active') }
+
+ def create_snippet(id)
+ params = {
+ id: id,
+ type: 'PersonalSnippet',
+ author_id: user.id,
+ file_name: 'foo',
+ content: 'bar'
+ }
+
+ snippets.create!(params)
+ end
+
+ it 'correctly schedules background migrations' do
+ create_snippet(1)
+ create_snippet(2)
+ create_snippet(3)
+ create_snippet(5)
+ create_snippet(7)
+ create_snippet(8)
+ create_snippet(10)
+
+ Sidekiq::Testing.fake! do
+ Timecop.freeze do
+ migrate!
+
+ expect(described_class::MIGRATION)
+ .to be_scheduled_delayed_migration(2.minutes, 1, 3)
+
+ expect(described_class::MIGRATION)
+ .to be_scheduled_delayed_migration(4.minutes, 5, 5)
+
+ expect(described_class::MIGRATION)
+ .to be_scheduled_delayed_migration(6.minutes, 7, 8)
+
+ expect(described_class::MIGRATION)
+ .to be_scheduled_delayed_migration(8.minutes, 10, 10)
+
+ expect(BackgroundMigrationWorker.jobs.size).to eq(4)
+ end
+ end
+ end
+end