mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-14 04:04:23 +00:00
Fix Rubocop: Hard delete paranoid associations
As much as the associated models act_as_paranoid, it doesnt make sense to keep them around after deleting the enterprise
This commit is contained in:
@@ -86,6 +86,26 @@ describe Enterprise do
|
||||
expect(DistributorShippingMethod.where(id: shipping_method_ids)).not_to exist
|
||||
end
|
||||
|
||||
it "destroys all enterprise_fees upon destroy" do
|
||||
enterprise = create(:enterprise)
|
||||
fee_ids = create_list(:enterprise_fee, 2, enterprise:).map(&:id)
|
||||
|
||||
expect(EnterpriseFee.where(id: fee_ids)).to exist
|
||||
enterprise.destroy
|
||||
expect(EnterpriseFee.where(id: fee_ids)).not_to exist
|
||||
end
|
||||
|
||||
it "destroys all vouchers upon destroy" do
|
||||
enterprise = create(:enterprise)
|
||||
voucher_ids = (1..2).map do |code|
|
||||
create(:voucher, enterprise:, code: "new code #{code}")
|
||||
end.map(&:id)
|
||||
|
||||
expect(Voucher.where(id: voucher_ids)).to exist
|
||||
enterprise.destroy
|
||||
expect(Voucher.where(id: voucher_ids)).not_to exist
|
||||
end
|
||||
|
||||
describe "relationships to other enterprises" do
|
||||
let(:e) { create(:distributor_enterprise) }
|
||||
let(:p) { create(:supplier_enterprise) }
|
||||
|
||||
Reference in New Issue
Block a user