This commit is contained in:
Rocky Duan 2012-06-26 15:59:08 -07:00
Родитель 485b11b1b7
Коммит 259f6f932a
1 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -26,14 +26,14 @@ namespace :db do
CommentThread.delete_all
Vote.delete_all
User.delete_all
depth_limit = YAML.load_file("config/application.yml")["depth_limit"]
level_limit = YAML.load_file("config/application.yml")["level_limit"]
(1..3).each do |question_id|
comment_thread = CommentThread.create! :commentable_type => "questions", :commentable_id => question_id
5.times do
comment_thread.root_comments.create :body => "top comment", :title => "top #{rand(10)}", :user_id => 1, :course_id => 1, :comment_thread_id => comment_thread.id
end
10.times do
comment = Comment.all.reject{|c| c.is_root? or c.depth - 1 >= depth_limit or c.comment_thread_id != comment_thread.id}.sample
comment = Comment.all.reject{|c| c.is_root? or c.depth >= level_limit or c.comment_thread_id != comment_thread.id}.sample
comment.children.create :body => "comment body", :title => "comment title #{rand(50)}", :user_id => 1, :course_id => 1, :comment_thread_id => comment_thread.id
end
end