Use a counter and append the index to make sure slugs are unique (#13981)

There's a unique index page on slugs that failed today during a PR
merge, where 'et' was the `Faker::Lorem.word` selected both times.

Add a suffix to the generated word to ensure these are unique and an
index collision doesn't happen.
This commit is contained in:
Daniel Uber 2021-06-14 09:55:12 -05:00 committed by GitHub
parent e38196df6f
commit 8158ea3cd2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -234,9 +234,9 @@ end
##############################################################################
seeder.create_if_none(Page) do
2.times do
2.times do |t|
Page.create!(
slug: Faker::Lorem.word,
slug: "#{Faker::Lorem.word}-#{t}",
body_html: "<p>#{Faker::Hipster.paragraph(sentence_count: 2)}</p>",
title: "#{Faker::Lorem.word} #{rand(100)}",
description: "A test page",