From 15e881b81a0621755ea499d38d97249dbb46efb3 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 15 Dec 2017 13:47:10 +0100 Subject: [PATCH] Increase dev seeds creating communities, topics and comments on topics & polls --- db/dev_seeds.rb | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 3c4462e85..57df045a1 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -614,13 +614,36 @@ section "Creating Poll Shifts for Poll Officers" do end end -section "Commenting Poll Questions" do +section "Creating Communities" do + Proposal.all.each { |proposal| proposal.update(community: Community.create) } + Budget::Investment.all.each { |investment| investment.update(community: Community.create) } +end + +section "Creating Communities Topics" do + Community.all.each do |community| + Topic.create(community: community, author: User.all.sample, + title: Faker::Lorem.sentence(3).truncate(60), description: Faker::Lorem.sentence) + end +end + +section "Commenting Polls" do 30.times do author = User.all.sample - question = Poll::Question.all.sample + poll = Poll.all.sample Comment.create!(user: author, - created_at: rand(question.created_at..Time.current), - commentable: question, + created_at: rand(poll.created_at..Time.current), + commentable: poll, + body: Faker::Lorem.sentence) + end +end + +section "Commenting Community Topics" do + 30.times do + author = User.all.sample + topic = Topic.all.sample + Comment.create!(user: author, + created_at: rand(topic.created_at..Time.current), + commentable: topic, body: Faker::Lorem.sentence) end end