A platform for community discussion. Free, open, simple.
DEV: Add discourse-dev seed for post voting reviewable (#35435)
Krzysztof Kotlarek760674cad3d1
diff --git a/plugins/discourse-post-voting/lib/discourse_dev/reviewable_post_voting_comment.rb b/plugins/discourse-post-voting/lib/discourse_dev/reviewable_post_voting_comment.rbnew file mode 100644index 00000000000..5c9b37bbb4c--- /dev/null+++ b/plugins/discourse-post-voting/lib/discourse_dev/reviewable_post_voting_comment.rb@@ -0,0 +1,30 @@+# 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+enddiff --git a/plugins/discourse-post-voting/plugin.rb b/plugins/discourse-post-voting/plugin.rbindex 05406a9f551..990fa46c9d3 100644--- a/plugins/discourse-post-voting/plugin.rb+++ b/plugins/discourse-post-voting/plugin.rb@@ -51,6 +51,11 @@ after_initialize doregister_reviewable_type ReviewablePostVotingComment+ if Rails.env.local? && enabled?+ require_relative "lib/discourse_dev/reviewable_post_voting_comment"+ DiscoursePluginRegistry.discourse_dev_populate_reviewable_types.add DiscourseDev::ReviewablePostVotingComment+ end+reloadable_patch doPost.include(PostVoting::PostExtension)Topic.include(PostVoting::TopicExtension)