diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-11-13 20:13:03 +0300 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2017-11-17 14:58:15 +0300 |
commit | 8b426b63d6044746a71a63b07a709bdc9a2ee832 (patch) | |
tree | 475e0a6346c21e8338510755eb4e808e26e52fb8 /spec/models/fork_network_member_spec.rb | |
parent | 4aa18590b3af27c9cb3cd3c2fc8c0a70e9a8758e (diff) |
Delete the fork network when removing the last membership
Diffstat (limited to 'spec/models/fork_network_member_spec.rb')
-rw-r--r-- | spec/models/fork_network_member_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/models/fork_network_member_spec.rb b/spec/models/fork_network_member_spec.rb index 532ca1fca8c..25bf596fddc 100644 --- a/spec/models/fork_network_member_spec.rb +++ b/spec/models/fork_network_member_spec.rb @@ -5,4 +5,22 @@ describe ForkNetworkMember do it { is_expected.to validate_presence_of(:project) } it { is_expected.to validate_presence_of(:fork_network) } end + + describe 'destroying a ForkNetworkMember' do + let(:fork_network_member) { create(:fork_network_member) } + let(:fork_network) { fork_network_member.fork_network } + + it 'removes the fork network if it was the last member' do + fork_network.fork_network_members.destroy_all + + expect(ForkNetwork.count).to eq(0) + end + + it 'does not destroy the fork network if there are members left' do + fork_network_member.destroy! + + # The root of the fork network is left + expect(ForkNetwork.count).to eq(1) + end + end end |