mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Enterprises have an `address_id` which must point to a valid `Spree::Address`. As Rubocop suggested, I restricted the deletion of addresses when they are still associated to an enterprise. Without declaring `dependent: :restrict`, trying to delete the address would raise `ActiveRecord::InvalidForeignKey`. Now it is more specific and raises `ActiveRecord::DeleteRestrictionError`. I didn't find code rescuing the InvalidForeignKey when deleting addresses. I actually think that we never delete addresses. So this change should not have any impact on the execution.