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:
Anthony Musyoki
2024-03-26 10:57:40 +03:00
parent 645cb10864
commit c2cbe4f0bf
2 changed files with 33 additions and 2 deletions

View File

@@ -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) }