diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-08-06 15:19:15 +0200 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-08-16 10:01:02 +0200 |
commit | 358675d09f6ba0fdcc4a089c6d1da6df9ff6d092 (patch) | |
tree | b91c1ecbb1ba0634c99430b55d05e4a9c59d357e /spec | |
parent | b78a69b06c165f7a463d5e0de69030346d9d5c72 (diff) | |
download | gitlab-ce-358675d09f6ba0fdcc4a089c6d1da6df9ff6d092.tar.gz |
Trigger iid logic from GitHub importer for milestones.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/github_import/bulk_importing_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb | 14 |
2 files changed, 25 insertions, 1 deletions
diff --git a/spec/lib/gitlab/github_import/bulk_importing_spec.rb b/spec/lib/gitlab/github_import/bulk_importing_spec.rb index 91229d9c7d4..861710f7e9b 100644 --- a/spec/lib/gitlab/github_import/bulk_importing_spec.rb +++ b/spec/lib/gitlab/github_import/bulk_importing_spec.rb @@ -58,5 +58,17 @@ describe Gitlab::GithubImport::BulkImporting do importer.bulk_insert(model, rows, batch_size: 5) end + + it 'calls pre_hook for each slice if given' do + rows = [{ title: 'Foo' }] * 10 + model = double(:model, table_name: 'kittens') + pre_hook = double('pre_hook', call: nil) + allow(Gitlab::Database).to receive(:bulk_insert) + + expect(pre_hook).to receive(:call).with(rows[0..4]) + expect(pre_hook).to receive(:call).with(rows[5..9]) + + importer.bulk_insert(model, rows, batch_size: 5, pre_hook: pre_hook) + end end end diff --git a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb index b1cac3b6e46..db0be760c7b 100644 --- a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb @@ -29,13 +29,25 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis expect(importer) .to receive(:bulk_insert) - .with(Milestone, [milestone_hash]) + .with(Milestone, [milestone_hash], any_args) expect(importer) .to receive(:build_milestones_cache) importer.execute end + + it 'tracks internal ids' do + milestone_hash = { iid: 1, title: '1.0', project_id: project.id } + allow(importer) + .to receive(:build_milestones) + .and_return([milestone_hash]) + + expect(InternalId).to receive(:track_greatest) + .with(nil, { project: project }, :milestones, 1, any_args) + + importer.execute + end end describe '#build_milestones' do |