Sha256: d8ad732d359892a49f888334b3b0acaca8e353086fa9133d848e2d15bf295319

Contents?: true

Size: 856 Bytes

Versions: 3

Compression:

Stored size: 856 Bytes

Contents

# frozen_string_literal: true

require 'discourse_dev/record'
require 'rails'
require 'faker'

module DiscourseDev
  class Group < Record

    DEFAULT_COUNT = 15.freeze

    def initialize(count = DEFAULT_COUNT)
      super(::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

3 entries across 3 versions & 1 rubygems

Version Path
discourse_dev-0.1.0 lib/discourse_dev/group.rb
discourse_dev-0.0.9 lib/discourse_dev/group.rb
discourse_dev-0.0.8 lib/discourse_dev/group.rb