discourse/lib/discourse_dev/group.rb
Vinoth Kannan 6abc45e57b
DEV: move discourse_dev gem to the core. (#13360)
And get avatar images from `discourse_dev_assets` gem.
2021-06-14 20:34:44 +05:30

39 lines
830 B
Ruby

# frozen_string_literal: true
require 'discourse_dev/record'
require 'rails'
require 'faker'
module DiscourseDev
class Group < Record
def initialize
super(::Group, DiscourseDev.config.group[:count])
end
def data
{
name: Faker::Discourse.unique.group,
public_exit: Faker::Boolean.boolean,
public_admission: Faker::Boolean.boolean,
primary_group: Faker::Boolean.boolean,
created_at: Faker::Time.between(from: DiscourseDev.config.start_date, to: DateTime.now),
}
end
def create!
super do |group|
if Faker::Boolean.boolean
group.add_owner(::Discourse.system_user)
group.allow_membership_requests = true
group.save!
end
end
end
def self.random
super(::Group)
end
end
end