spree/spree — pull request #4805 by mtuckergd (2014-06-09 17:41:07+00:00)
Title: Product Slug improvements

This PR modifies 3 behaviors of the product slug field:

1. Added unique validation on the slug field. A unique index already exists on this database field, so there is no reason not to have a unique valudation on the model as well

2. Modified slug generation to have a fallback, instead of relying solely on product name. See slug_candidates. This will attempt to use name-sku if name is already in use.

3. Restored "punch" functionality on product destroy. This will prepend a timestamp before the slug when a product is deleted, effectively releasing the "permalink" value for use by another product. This isn't strictly necessary, as Spree allows you to search deleted products in the admin and manually rename the value. However, it seems prudent to free up the permalink value when product is deleted. In terms of SEO, it's preferable to use the name-based value and not have a guid appended. #2 above should help with this, but I see no beneficial reason to retain slug value for a deleted product.

Also did some minor cleanup of the spec file while I was in there adding specs.