test: Improve test suite setup

Этот коммит содержится в:
Mattia Roccoberton
2025-04-13 15:00:22 +02:00
родитель d19fc7ddfc
Коммит 6cbb39daad
18 изменённых файлов: 114 добавлений и 209 удалений

Просмотреть файл

@@ -7,7 +7,8 @@ end
(11..20).each do |i|
age = 21 + 3 * (i - 10)
attrs = { name: "Author #{i}", age: age, email: "some@email#{i}.com" }
Author.find_or_create_by!(attrs) do |author|
Author.find_or_create_by!(name: "Author #{i}") do |author|
author.assign_attributes(attrs)
author.profile = Profile.new(description: "Profile description for Author #{i}") if (i % 3).zero?
end
end
@@ -19,6 +20,8 @@ tags = Tag.where.not(name: 'A test tag').pluck(:id)
title: "Post #{i}",
author_id: authors.sample,
position: rand(100),
summary: "<p><em>Summary</em> for post #{i}</p>",
description: "<p><strong>Some bold</strong> <em>Some italic</em> <u>Some underline</u> [#{i}]</p>",
created_at: Time.now - rand(3600).seconds
}
attrs[:category] = 'news' if (i % 4).zero?