discourse/plugins/discourse-post-voting/lib/discourse_dev/reviewable_post_voting_comment.rb
Krzysztof Kotlarek 760674cad3
DEV: Add discourse-dev seed for post voting reviewable (#35435)
Add DiscourseDev::ReviewablePostVotingPostVotingComment to generate a
post voting comment reviewable.
2025-10-21 09:57:05 +08:00

30 lines
877 B
Ruby

# frozen_string_literal: true
module DiscourseDev
class ReviewablePostVotingComment < Reviewable
def populate!
topic = Topic.new.create!
topic.update_column(:subtype, ::Topic::POST_VOTING_SUBTYPE)
post = topic.posts.first
comment =
PostVotingComment.create!(
user: @users.sample,
post: post,
raw: "This is a comment for post #{post.id}",
)
user = @users.sample
reviewable =
::ReviewablePostVotingComment.needs_review!(
created_by: user,
target: comment,
reviewable_by_moderator: true,
topic: topic,
target_created_by: comment.user,
payload: {
comment_cooked: comment.cooked,
},
)
reviewable.add_score(user, ReviewableScore.types[:inappropriate], force_review: true)
end
end
end