2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-28 10:38:12 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe ForkNetworkMember do
|
2017-09-28 10:38:12 -04:00
|
|
|
describe 'validations' do
|
|
|
|
it { is_expected.to validate_presence_of(:project) }
|
|
|
|
it { is_expected.to validate_presence_of(:fork_network) }
|
|
|
|
end
|
2017-11-13 12:13:03 -05:00
|
|
|
|
|
|
|
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
|
2020-05-28 17:08:22 -04:00
|
|
|
fork_network.fork_network_members.destroy_all # rubocop: disable Cop/DestroyAll
|
2017-11-13 12:13:03 -05:00
|
|
|
|
|
|
|
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
|
2017-09-28 10:38:12 -04:00
|
|
|
end
|