summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-11-15 10:13:57 +0100
committerBob Van Landuyt <bob@vanlanduyt.co>2017-11-15 10:13:57 +0100
commitf961744bdea16159f22d9febf463a9f82157eafe (patch)
treea72f8b6d9600ed12bc9035ce8b45975611279fed
parentf2997af4d5cdec3266d3178edeedc36d4e590062 (diff)
downloadgitlab-ce-bvl-isolate-fork-network-background-migrations.tar.gz
Isolate the fork network background migrationsbvl-isolate-fork-network-background-migrations
Before the `PopulateForkNetworksRange` spec would also call the `CreateForkNetworkMemberships` which we would count on in the spec. With this, I'm isolating that, and counting only records created in this particular migration instead.
-rw-r--r--spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb22
1 files changed, 11 insertions, 11 deletions
diff --git a/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb b/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb
index 2c2684a6fc9..994992f79d4 100644
--- a/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb
@@ -3,12 +3,9 @@ require 'spec_helper'
describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, schema: 20170929131201 do
let(:migration) { described_class.new }
let(:base1) { create(:project) }
- let(:base1_fork1) { create(:project) }
- let(:base1_fork2) { create(:project) }
let(:base2) { create(:project) }
let(:base2_fork1) { create(:project) }
- let(:base2_fork2) { create(:project) }
let!(:forked_project_links) { table(:forked_project_links) }
let!(:fork_networks) { table(:fork_networks) }
@@ -21,21 +18,24 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
# A normal fork link
forked_project_links.create(id: 1,
forked_from_project_id: base1.id,
- forked_to_project_id: base1_fork1.id)
+ forked_to_project_id: create(:project).id)
forked_project_links.create(id: 2,
forked_from_project_id: base1.id,
- forked_to_project_id: base1_fork2.id)
-
+ forked_to_project_id: create(:project).id)
forked_project_links.create(id: 3,
forked_from_project_id: base2.id,
forked_to_project_id: base2_fork1.id)
+
+ # create a fork of a fork
forked_project_links.create(id: 4,
forked_from_project_id: base2_fork1.id,
forked_to_project_id: create(:project).id)
-
forked_project_links.create(id: 5,
- forked_from_project_id: base2.id,
- forked_to_project_id: base2_fork2.id)
+ forked_from_project_id: create(:project).id,
+ forked_to_project_id: create(:project).id)
+
+ # Stub out the calls to the other migrations
+ allow(BackgroundMigrationWorker).to receive(:perform_in)
migration.perform(1, 3)
end
@@ -80,11 +80,11 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
end
it 'only processes a single batch of links at a time' do
- expect(fork_network_members.count).to eq(5)
+ expect(fork_networks.count).to eq(2)
migration.perform(3, 5)
- expect(fork_network_members.count).to eq(7)
+ expect(fork_networks.count).to eq(3)
end
it 'can be repeated without effect' do