Ensure model properties in factories are unique (#5190)
This commit is contained in:
parent
b602b7b91f
commit
55b691c980
5 changed files with 11 additions and 6 deletions
|
|
@ -1,7 +1,9 @@
|
|||
FactoryBot.define do
|
||||
sequence(:title) { |n| "#{Faker::Book.title}#{n}" }
|
||||
|
||||
factory :article do
|
||||
transient do
|
||||
title { Faker::Book.title + " #{rand(1000)}" }
|
||||
title { generate :title }
|
||||
published { true }
|
||||
date { "01/01/2015" }
|
||||
tags { Faker::Hipster.words(number: 4).join(", ") }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ FactoryBot.define do
|
|||
image_path = Rails.root.join("spec/support/fixtures/images/image1.jpeg")
|
||||
|
||||
factory :badge do
|
||||
title { Faker::Book.title + " #{rand(1000)}" }
|
||||
sequence(:title) { |n| "#{Faker::Book.title}-#{n}" }
|
||||
description { Faker::Lorem.sentence }
|
||||
badge_image { Rack::Test::UploadedFile.new(image_path, "image/jpeg") }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
FactoryBot.define do
|
||||
factory :chat_channel do
|
||||
channel_type { "open" }
|
||||
slug { rand(10_000_000_000).to_s }
|
||||
sequence(:slug) { |n| "slug-#{n}" }
|
||||
end
|
||||
|
||||
trait :workshop do
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
FactoryBot.define do
|
||||
factory :collection do
|
||||
user
|
||||
slug { "word-#{rand(10_000)}" }
|
||||
sequence(:slug) { |n| "slug-#{n}" }
|
||||
end
|
||||
|
||||
trait :with_articles do
|
||||
|
|
|
|||
|
|
@ -1,13 +1,16 @@
|
|||
FactoryBot.define do
|
||||
sequence(:github_id_code) { |n| n }
|
||||
sequence(:url) { |n| "#{Faker::Internet.url}#{n}" }
|
||||
|
||||
factory :github_repo do
|
||||
user
|
||||
name { Faker::Book.title }
|
||||
url { Faker::Internet.url }
|
||||
url { generate :url }
|
||||
description { Faker::Book.title }
|
||||
language { Faker::Book.title }
|
||||
bytes_size { rand(100_000) }
|
||||
watchers_count { rand(100_000) }
|
||||
github_id_code { rand(100_000) }
|
||||
github_id_code { generate :github_id_code }
|
||||
stargazers_count { rand(100_000) }
|
||||
featured { true }
|
||||
fork { false }
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue