Sha256: f4d67adc04573050fff3f181c1b8f9714dc7eee485615b1133a2714736f62363

Contents?: true

Size: 830 Bytes

Versions: 2

Compression:

Stored size: 830 Bytes

Contents

# 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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
discourse_dev-0.2.1 lib/discourse_dev/group.rb
discourse_dev-0.2.0 lib/discourse_dev/group.rb