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:
authorBob Van Landuyt <bob@vanlanduyt.co>2017-11-14 14:39:26 +0300
committerBob Van Landuyt <bob@vanlanduyt.co>2017-11-17 14:58:15 +0300
commit8f84369ae105c59a0c5cd947edb352fd616c4335 (patch)
tree56d680995c27815b15742341e0e803d958dff619 /spec/migrations/remove_empty_fork_networks_spec.rb
parent8b426b63d6044746a71a63b07a709bdc9a2ee832 (diff)
Delete orphaned fork networks in a migration
Diffstat (limited to 'spec/migrations/remove_empty_fork_networks_spec.rb')
-rw-r--r--spec/migrations/remove_empty_fork_networks_spec.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/spec/migrations/remove_empty_fork_networks_spec.rb b/spec/migrations/remove_empty_fork_networks_spec.rb
new file mode 100644
index 00000000000..cf6ae5cda74
--- /dev/null
+++ b/spec/migrations/remove_empty_fork_networks_spec.rb
@@ -0,0 +1,24 @@
+require 'spec_helper'
+require Rails.root.join('db', 'post_migrate', '20171114104051_remove_empty_fork_networks.rb')
+
+describe RemoveEmptyForkNetworks, :migration do
+ let!(:fork_networks) { table(:fork_networks) }
+
+ let(:deleted_project) { create(:project) }
+ let!(:empty_network) { create(:fork_network, id: 1, root_project_id: deleted_project.id) }
+ let!(:other_network) { create(:fork_network, id: 2, root_project_id: create(:project).id) }
+
+ before do
+ deleted_project.destroy!
+ end
+
+ it 'deletes only the fork network without members' do
+ expect(fork_networks.count).to eq(2)
+
+ migrate!
+
+ expect(fork_networks.find_by(id: empty_network.id)).to be_nil
+ expect(fork_networks.find_by(id: other_network.id)).not_to be_nil
+ expect(fork_networks.count).to eq(1)
+ end
+end