mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 20:51:50 +08:00
0a5f548635
As part of this move, we are also renaming `discourse-chat` to `chat`.
20 lines
505 B
Ruby
20 lines
505 B
Ruby
# frozen_string_literal: true
|
|
|
|
module ChatHelper
|
|
def self.make_messages!(chatable, users, count)
|
|
users = [users] unless Array === users
|
|
raise ArgumentError if users.length <= 0
|
|
|
|
chatable = Fabricate(:category) unless chatable
|
|
chat_channel = Fabricate(:chat_channel, chatable: chatable)
|
|
|
|
count.times do |n|
|
|
ChatMessage.new(
|
|
chat_channel: chat_channel,
|
|
user: users[n % users.length],
|
|
message: "Chat message for test #{n}",
|
|
).save!
|
|
end
|
|
end
|
|
end
|