Sha256: e829ccefe925153615f136e53fc23de63fa65dea04b5d4ef3c39c38039378660

Contents?: true

Size: 1.8 KB

Versions: 6

Compression:

Stored size: 1.8 KB

Contents

class TopicsDataset < Dataset::Base
  uses :forum_readers, :forum_pages, :forums
  
  def load  
    create_topic "older", :reader => readers(:normal), :forum => forums(:public), :body => 'this goes in the first post really', :created_at => 4.days.ago, :replied_at => 2.days.ago
    create_topic "newer", :reader => readers(:normal), :forum => forums(:public), :body => 'this goes in the first post really', :created_at => 2.days.ago, :replied_at => 1.day.ago
    create_topic "sticky", :reader => readers(:normal), :forum => forums(:private), :body => 'this goes in the first post really', :created_at => 2.days.ago, :replied_at => 3.days.ago, :sticky => true
    create_topic "locked", :reader => readers(:normal), :forum => forums(:public), :body => 'this goes in the first post really', :locked => true, :replied_at => 1.year.ago
    create_topic "private", :reader => readers(:normal), :forum => forums(:private), :body => 'this goes in the first post really', :created_at => 2.days.ago, :replied_at => 1.day.ago
    create_topic "minimal", :reader => readers(:normal), :forum => forums(:misc), :body => 'this goes in the first post really'
    create_topic "comments", :reader => readers(:normal), :forum => forums(:comments), :body => 'this goes in the first post really', :locked => false, :page => pages(:commentable)
  end
  
  helpers do
    def create_topic(name, attributes={})
      attributes = topic_attributes(attributes.update(:name => name))
      create_model :topic, name.symbolize, attributes
    end
  end
 
  def topic_attributes(attributes={})
    name = attributes[:name] || "A topic"
    att = {
      :name => name,
      :reader => readers(:normal),
      :created_at => Time.now
    }.merge(attributes)
    attributes[:site_id] ||= site_id(:test) if Reader.reflect_on_association(:site)
    att
  end
 
 
 
 
 
 
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
radiant-forum-extension-1.2.1 spec/datasets/topics_dataset.rb
radiant-forum-extension-1.1.2 spec/datasets/topics_dataset.rb
radiant-forum-extension-1.1.1 spec/datasets/topics_dataset.rb
radiant-forum-extension-1.1.0 spec/datasets/topics_dataset.rb
radiant-forum-extension-0.6.1 spec/datasets/topics_dataset.rb
radiant-forum-extension-0.6.0 spec/datasets/topics_dataset.rb