Sha256: c9c9e02725263ae6cc8793423774a3c52786972666a96cebf3ab56b19691f686
Contents?: true
Size: 1.11 KB
Versions: 6
Compression:
Stored size: 1.11 KB
Contents
class PostsDataset < Dataset::Base uses :topics, :forum_readers def load Page.current_site = sites(:test) if defined? Site create_post "First", :topic => topics(:older), :created_at => 2.days.ago, :body => 'first reply: to public topic' create_post "Second", :topic => topics(:older), :created_at => 1.day.ago, :body => 'second reply: to public topic' create_post "Third", :topic => topics(:private), :created_at => 4.hours.ago, :body => 'third reply: to private topic' create_post "Comment", :topic => topics(:comments), :created_at => 1.day.ago, :body => 'first comment on page' end helpers do def create_post(name, attributes={}) attributes = post_attributes(attributes.update(:name => name)) create_model :post, name.symbolize, attributes end end def post_attributes(attributes={}) name = attributes[:name] || "A topic" att = { :name => name, :reader => readers(:normal), :created_at => Time.now }.merge(attributes) att[:site_id] ||= site_id(:test) if Reader.reflect_on_association(:site) att end end
Version data entries
6 entries across 6 versions & 1 rubygems