diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-18 00:08:29 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-18 00:08:29 +0300 |
commit | 40254b9ace2a74a3c9f1cc51a1b1d5e3e78c1ae9 (patch) | |
tree | 9b735ef933178be36d35088f3acab2d9b75dbbad /spec/migrations | |
parent | 22a0d312ae82e7dda3073d5d1a5a766d7641738d (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb new file mode 100644 index 00000000000..0453ac87436 --- /dev/null +++ b/spec/migrations/20190924152703_migrate_issue_trackers_data_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20190924152703_migrate_issue_trackers_data.rb') + +describe MigrateIssueTrackersData, :migration do + let(:services) { table(:services) } + let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData } + let(:migration_name) { migration_class.to_s.demodulize } + + let(:properties) do + { + 'url' => 'http://example.com' + } + end + let!(:jira_service) do + services.create(id: 10, type: 'JiraService', properties: properties, category: 'issue_tracker') + end + let!(:jira_service_nil) do + services.create(id: 11, type: 'JiraService', properties: nil, category: 'issue_tracker') + end + let!(:bugzilla_service) do + services.create(id: 12, type: 'BugzillaService', properties: properties, category: 'issue_tracker') + end + let!(:youtrack_service) do + services.create(id: 13, type: 'YoutrackService', properties: properties, category: 'issue_tracker') + end + let!(:youtrack_service_empty) do + services.create(id: 14, type: 'YoutrackService', properties: '', category: 'issue_tracker') + end + let!(:gitlab_service) do + services.create(id: 15, type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker') + end + let!(:gitlab_service_empty) do + services.create(id: 16, type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker') + end + let!(:other_service) do + services.create(id: 17, type: 'OtherService', properties: properties, category: 'other_category') + end + + before do + stub_const("#{described_class}::BATCH_SIZE", 2) + end + + it 'schedules background migrations at correct time' do + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(migration_name).to be_scheduled_delayed_migration(3.minutes, jira_service.id, bugzilla_service.id) + expect(migration_name).to be_scheduled_delayed_migration(6.minutes, youtrack_service.id, gitlab_service.id) + expect(BackgroundMigrationWorker.jobs.size).to eq(2) + end + end + end +end |