From 40e6c3d77cf0b287b288da48d451c56015ca43b5 Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Sun, 19 Jul 2020 04:01:26 +0000 Subject: [PATCH] Update test factories to run without input of instances --- test/factories/forum_post.rb | 1 + test/factories/mod_action.rb | 1 + test/factories/post_disapproval.rb | 4 ++-- test/factories/post_flag.rb | 2 +- test/factories/post_replacement.rb | 1 + test/factories/post_vote.rb | 2 +- test/factories/tag_alias.rb | 4 ++-- test/factories/tag_implication.rb | 4 ++-- 8 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/factories/forum_post.rb b/test/factories/forum_post.rb index acc151a70..09e65918a 100644 --- a/test/factories/forum_post.rb +++ b/test/factories/forum_post.rb @@ -1,6 +1,7 @@ FactoryBot.define do factory(:forum_post) do creator + topic factory: :forum_topic body {FFaker::Lorem.sentences.join(" ")} end end diff --git a/test/factories/mod_action.rb b/test/factories/mod_action.rb index 4be3425e2..18ae08903 100644 --- a/test/factories/mod_action.rb +++ b/test/factories/mod_action.rb @@ -2,5 +2,6 @@ FactoryBot.define do factory(:mod_action) do creator :factory => :user description {"1234"} + category {"other"} end end diff --git a/test/factories/post_disapproval.rb b/test/factories/post_disapproval.rb index 55052a2b5..89f5717ef 100644 --- a/test/factories/post_disapproval.rb +++ b/test/factories/post_disapproval.rb @@ -1,7 +1,7 @@ FactoryBot.define do factory(:post_disapproval) do - user - post + user factory: :moderator_user + post factory: :post, is_pending: true reason { PostDisapproval::REASONS.sample } message { FFaker::Lorem.sentence } end diff --git a/test/factories/post_flag.rb b/test/factories/post_flag.rb index ed7c3d942..f0f214371 100644 --- a/test/factories/post_flag.rb +++ b/test/factories/post_flag.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory(:post_flag) do - creator + creator factory: :user, created_at: 2.weeks.ago post reason {"xxx"} is_resolved {false} diff --git a/test/factories/post_replacement.rb b/test/factories/post_replacement.rb index 119242c0a..43108423a 100644 --- a/test/factories/post_replacement.rb +++ b/test/factories/post_replacement.rb @@ -1,5 +1,6 @@ FactoryBot.define do factory(:post_replacement) do + post factory: :post, source: FFaker::Internet.http_url original_url { FFaker::Internet.http_url } replacement_url { FFaker::Internet.http_url } end diff --git a/test/factories/post_vote.rb b/test/factories/post_vote.rb index 8a360bd39..4d1e6b3b9 100644 --- a/test/factories/post_vote.rb +++ b/test/factories/post_vote.rb @@ -1,6 +1,6 @@ FactoryBot.define do factory(:post_vote) do - user + user factory: :gold_user post score { [-1, 1].sample } end diff --git a/test/factories/tag_alias.rb b/test/factories/tag_alias.rb index 3ab1efb46..c280d7dab 100644 --- a/test/factories/tag_alias.rb +++ b/test/factories/tag_alias.rb @@ -1,8 +1,8 @@ FactoryBot.define do factory :tag_alias do creator - antecedent_name {"aaa"} - consequent_name {"bbb"} + antecedent_name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"} + consequent_name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"} status {"active"} skip_secondary_validations {true} end diff --git a/test/factories/tag_implication.rb b/test/factories/tag_implication.rb index c1f0d7fd5..08677a9d2 100644 --- a/test/factories/tag_implication.rb +++ b/test/factories/tag_implication.rb @@ -1,8 +1,8 @@ FactoryBot.define do factory :tag_implication do creator - antecedent_name {"aaa"} - consequent_name {"bbb"} + antecedent_name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"} + consequent_name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"} status {"active"} skip_secondary_validations {true} end