Class: DiscourseDev::User
Constant Summary
Constants inherited from Record
Instance Attribute Summary
Attributes inherited from Record
Instance Method Summary collapse
- #create! ⇒ Object
- #data ⇒ Object
-
#initialize(count = DEFAULT_COUNT) ⇒ User
constructor
A new instance of User.
Methods inherited from Record
Constructor Details
#initialize(count = DEFAULT_COUNT) ⇒ User
Returns a new instance of User.
10 11 12 13 14 |
# File 'lib/discourse_dev/user.rb', line 10 def initialize(count = DEFAULT_COUNT) super(::User, count) @groups = ::Group.where(automatic: false) @group_count = @groups.count end |
Instance Method Details
#create! ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/discourse_dev/user.rb', line 32 def create! super do |user| Faker::Number.between(from: 0, to: 2).times do offset = rand(@group_count) group = @groups.offset(offset).first group.add(user) end end end |
#data ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/discourse_dev/user.rb', line 16 def data name = Faker::Name.name email = Faker::Internet.email(name: name) username = Faker::Internet.username(specifier: name)[0, SiteSetting.max_username_length] username_lower = username.downcase { name: name, email: email, username: username, username_lower: username_lower, moderator: Faker::Boolean.boolean(true_ratio: 0.1), trust_level: Faker::Number.between(from: 1, to: 4) } end |