fork_network_member_spec.rb 786 Bytes
Newer Older
1 2 3 4 5 6 7
require 'spec_helper'

describe ForkNetworkMember do
  describe 'validations' do
    it { is_expected.to validate_presence_of(:project) }
    it { is_expected.to validate_presence_of(:fork_network) }
  end
8 9 10 11 12 13

  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
14
      fork_network.fork_network_members.destroy_all # rubocop: disable DestroyAll
15 16 17 18 19 20 21 22 23 24 25

      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
26
end