[Tests] Improve some factories

A forum topic must always contain a forum post, and creating things shouldn't
run into throttles. If I want to test that I opt in explicitly.
This commit is contained in:
Earlopain 2022-04-07 17:52:35 +02:00
parent 6561391fe7
commit ec658c4cb3
No known key found for this signature in database
GPG Key ID: 6CFB948E15246897
4 changed files with 17 additions and 4 deletions

View File

@ -1,8 +1,20 @@
FactoryBot.define do
factory(:forum_topic) do
title {FFaker::Lorem.words.join(" ")}
title { FFaker::Lorem.words.join(" ") }
is_sticky { false }
is_locked { false }
category_id { Danbooru.config.alias_implication_forum_category }
transient do
body { FFaker::Lorem.sentences.join(" ") }
end
after(:build) do |topic, evaluator|
topic.original_post ||= build(:forum_post, topic: topic, body: evaluator.body)
end
before(:create) do |topic, evaluator|
topic.original_post ||= build(:forum_post, topic: topic, body: evaluator.body)
end
end
end

View File

@ -1,11 +1,11 @@
FactoryBot.define do
factory(:note) do
post
post { create(:post) }
x { 1 }
y { 1 }
width { 1 }
height { 1 }
is_active { true }
body {FFaker::Lorem.sentences.join(" ")}
body { FFaker::Lorem.sentences.join(" ") }
end
end

View File

@ -3,7 +3,7 @@ FactoryBot.define do
sequence :md5 do |n|
n.to_s
end
uploader :factory => :user
uploader { create(:user, created_at: 2.weeks.ago) }
uploader_ip_addr { "127.0.0.1" }
tag_string { "tag1 tag2" }
tag_count { 2 }

View File

@ -1,6 +1,7 @@
FactoryBot.define do
factory(:post_replacement) do
creator_ip_addr { "127.0.0.1" }
creator { create(:user, created_at: 2.weeks.ago) }
replacement_url { FFaker::Internet.http_url }
reason { FFaker::Lorem.words.join(" ") }