Class: DiscourseDev::Group
Constant Summary collapse
- DEFAULT_COUNT =
15.freeze
Instance Attribute Summary
Attributes inherited from Record
Instance Method Summary collapse
- #create! ⇒ Object
- #data ⇒ Object
-
#initialize(count = DEFAULT_COUNT) ⇒ Group
constructor
A new instance of Group.
Methods inherited from Record
Constructor Details
#initialize(count = DEFAULT_COUNT) ⇒ Group
12 13 14 15 |
# File 'lib/discourse_dev/group.rb', line 12 def initialize(count = DEFAULT_COUNT) super(::Group, count) @existing_names = ::Group.where(automatic: false).pluck(:name) end |
Instance Method Details
#create! ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/discourse_dev/group.rb', line 34 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 |
#data ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/discourse_dev/group.rb', line 17 def data name = Faker::Discourse.group while @existing_names.include? name name = Faker::Company.profession.gsub(" ", "-") end @existing_names << name { name: name, public_exit: Faker::Boolean.boolean, public_admission: Faker::Boolean.boolean, primary_group: Faker::Boolean.boolean } end |