summaryrefslogtreecommitdiff
path: root/spec/migrations
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-11-17 14:21:36 +0000
committerDouwe Maan <douwe@gitlab.com>2017-11-17 14:21:36 +0000
commit5c0ba938aa55009d891da25abc66b0fb3bd7d43b (patch)
treefa931efa6072dab8c0e58b19b302d0ccf0f8bec8 /spec/migrations
parent6d36c3b5de7772415b1176b8247c34053b826a74 (diff)
parent8f84369ae105c59a0c5cd947edb352fd616c4335 (diff)
downloadgitlab-ce-5c0ba938aa55009d891da25abc66b0fb3bd7d43b.tar.gz
Merge branch 'bvl-delete-empty-fork-networks' into 'master'
Delete empty fork networks See merge request gitlab-org/gitlab-ce!15373
Diffstat (limited to 'spec/migrations')
-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