mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 13:42:57 +08:00
36 lines
776 B
Ruby
36 lines
776 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
require "discourse_dev/reviewable"
|
||
|
require "faker"
|
||
|
|
||
|
module DiscourseDev
|
||
|
class ReviewableFlaggedPost < Reviewable
|
||
|
def populate!
|
||
|
types = PostActionType.notify_flag_types.keys
|
||
|
|
||
|
posts = @posts.sample(types.size + 1)
|
||
|
users = @users.sample(types.size + 3)
|
||
|
|
||
|
types.each do |type|
|
||
|
post = posts.pop
|
||
|
user = users.pop
|
||
|
|
||
|
reason = nil
|
||
|
|
||
|
reason = Faker::Lorem.paragraph if type == :notify_moderators
|
||
|
|
||
|
PostActionCreator.create(user, post, type, reason:)
|
||
|
end
|
||
|
|
||
|
posts.pop.tap do |post|
|
||
|
type = types.excluding(:notify_moderators).sample
|
||
|
3.times do
|
||
|
user = users.pop
|
||
|
|
||
|
PostActionCreator.create(user, post, type)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|
||
|
end
|