diff options
Diffstat (limited to 'spec/models/group_spec.rb')
-rw-r--r-- | spec/models/group_spec.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index cc8e744a15c..0acf2b96b74 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -31,6 +31,7 @@ RSpec.describe Group do it { is_expected.to have_one(:dependency_proxy_setting) } it { is_expected.to have_many(:dependency_proxy_blobs) } it { is_expected.to have_many(:dependency_proxy_manifests) } + it { is_expected.to have_many(:debian_distributions).class_name('Packages::Debian::GroupDistribution').dependent(:destroy) } describe '#members & #requesters' do let(:requester) { create(:user) } @@ -1751,4 +1752,23 @@ RSpec.describe Group do it { is_expected.to eq(false) } end end + + describe 'with Debian Distributions' do + subject { create(:group) } + + let!(:distributions) { create_list(:debian_group_distribution, 2, :with_file, container: subject) } + + it 'removes distribution files on removal' do + distribution_file_paths = distributions.map do |distribution| + distribution.file.path + end + + expect { subject.destroy } + .to change { + distribution_file_paths.select do |path| + File.exist? path + end.length + }.from(distribution_file_paths.length).to(0) + end + end end |