Class: DiscourseDev::Topic
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) ⇒ Topic
constructor
A new instance of Topic.
- #tags ⇒ Object
Methods inherited from Record
Constructor Details
#initialize(count = DEFAULT_COUNT) ⇒ Topic
Returns a new instance of Topic.
9 10 11 12 13 |
# File 'lib/discourse_dev/topic.rb', line 9 def initialize(count = DEFAULT_COUNT) super(::Topic, count) @category_ids = ::Category.pluck(:id) @user_count = ::User.count end |
Instance Method Details
#create! ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/discourse_dev/topic.rb', line 37 def create! offset = rand(@user_count) user = ::User.offset(offset).first PostCreator.new(user, data).create! putc "." end |
#data ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/discourse_dev/topic.rb', line 15 def data { title: Faker::Lorem.sentence(word_count: 3, supplemental: true, random_words_to_add: 4).chomp(".")[0, SiteSetting.max_topic_title_length], raw: Faker::Markdown.sandwich(sentences: 5), category: @category_ids.sample, tags: , topic_opts: { custom_fields: { dev_sample: true } }, skip_validations: true } end |
#tags ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/discourse_dev/topic.rb', line 26 def = [] keys = ["model", "make", "manufacture"] Faker::Number.between(from: 0, to: 3).times do |index| << Faker::Vehicle.send(keys[index]) end end |