2020-03-13 15:44:24 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
2021-01-29 00:20:46 +05:30
|
|
|
require_migration!('migrate_issue_trackers_data')
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe MigrateIssueTrackersData do
|
2020-03-13 15:44:24 +05:30
|
|
|
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
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let!(:jira_integration) do
|
2021-02-22 17:27:13 +05:30
|
|
|
services.create!(type: 'JiraService', properties: properties, category: 'issue_tracker')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let!(:jira_integration_nil) do
|
2021-02-22 17:27:13 +05:30
|
|
|
services.create!(type: 'JiraService', properties: nil, category: 'issue_tracker')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
let!(:bugzilla_integration) do
|
2021-02-22 17:27:13 +05:30
|
|
|
services.create!(type: 'BugzillaService', properties: properties, category: 'issue_tracker')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let!(:youtrack_integration) do
|
2021-02-22 17:27:13 +05:30
|
|
|
services.create!(type: 'YoutrackService', properties: properties, category: 'issue_tracker')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
let!(:youtrack_integration_empty) do
|
2021-02-22 17:27:13 +05:30
|
|
|
services.create!(type: 'YoutrackService', properties: '', category: 'issue_tracker')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
let!(:gitlab_service) do
|
2021-02-22 17:27:13 +05:30
|
|
|
services.create!(type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
let!(:gitlab_service_empty) do
|
2021-02-22 17:27:13 +05:30
|
|
|
services.create!(type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
let!(:other_service) do
|
2021-02-22 17:27:13 +05:30
|
|
|
services.create!(type: 'OtherService', properties: properties, category: 'other_category')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
stub_const("#{described_class}::BATCH_SIZE", 2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'schedules background migrations at correct time' do
|
|
|
|
Sidekiq::Testing.fake! do
|
2020-11-24 15:15:51 +05:30
|
|
|
freeze_time do
|
2020-03-13 15:44:24 +05:30
|
|
|
migrate!
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
expect(migration_name).to be_scheduled_delayed_migration(3.minutes, jira_integration.id, bugzilla_integration.id)
|
|
|
|
expect(migration_name).to be_scheduled_delayed_migration(6.minutes, youtrack_integration.id, gitlab_service.id)
|
2020-03-13 15:44:24 +05:30
|
|
|
expect(BackgroundMigrationWorker.jobs.size).to eq(2)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|