mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-13 04:00:21 +00:00
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:
@@ -35,6 +35,25 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
describe "permalink" do
|
||||
let(:name) { "Banana Permanenta" }
|
||||
|
||||
it "generates a unique permalink" do
|
||||
product1 = create(:product, name: "Banana Permanenta", permalink: nil)
|
||||
product2 = create(:product, name: "Banana Permanenta", permalink: nil)
|
||||
expect(product2.permalink).to_not eq product1.permalink
|
||||
# "banana-permanenta" != "banana-permanenta-1" # generated by Spree
|
||||
end
|
||||
|
||||
it "generates a unique permalink considering deleted products" do
|
||||
product1 = create(:product, name: "Banana Permanenta", permalink: nil)
|
||||
product1.destroy
|
||||
product2 = create(:product, name: "Banana Permanenta", permalink: nil)
|
||||
expect(product2.permalink).to_not eq product1.permalink
|
||||
# "banana-permanenta" != "banana-permanenta1" # generated by OFN
|
||||
end
|
||||
end
|
||||
|
||||
describe "tax category" do
|
||||
context "when a tax category is required" do
|
||||
it "is invalid when a tax category is not provided" do
|
||||
|
||||
Reference in New Issue
Block a user