Sha256: baedf3c6b68c1b8f79264a82a63a4e50c3bf4864a8d77fcc0dd40dba3dd808b3

Contents?: true

Size: 758 Bytes

Versions: 3

Compression:

Stored size: 758 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
      }
    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.0.7 lib/discourse_dev/group.rb
discourse_dev-0.0.5 lib/discourse_dev/group.rb
discourse_dev-0.0.4 lib/discourse_dev/group.rb