Consider deleted products when creating permalinks

https://github.com/openfoodfoundation/openfoodnetwork/issues/3844

Spree's implementation and our implementation to create a unique
permalink failed to notice conflicts with soft-deleted products. This
patch looks at deleted products as well.
This commit is contained in:
Maikel Linke
2019-06-11 18:03:42 +10:00
parent 568e3003ba
commit a10bb5acbd
3 changed files with 44 additions and 1 deletions

View File

@@ -252,6 +252,7 @@ Spree::Product.class_eval do
raise
end
# Spree creates a permalink already but our implementation fixes an edge case.
def sanitize_permalink
if permalink.blank? || permalink_changed?
requested = permalink.presence || permalink_was.presence || name.presence || 'product'