Sha256: 713e02905d7568a20e2f3ac72f5e05e700728d35dfa669f7b143580b0ea17a64

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

class AssetsDataset < Dataset::Base
  uses :home_page
  
  def load
    create_page "pictured", :slug => 'pictured' do
      create_asset "test1", :caption => "testing"
      create_asset "test2", :caption => "also testing"
    end
    create_asset "video", :asset_content_type => 'video/mpeg', :asset_file_name => 'asset.mpg'
    create_asset "audio", :asset_content_type => 'audio/mp3', :asset_file_name => 'asset.mp3'
    create_asset "document", :asset_content_type => 'application/msword', :asset_file_name => 'asset.doc'
  end
  
  helpers do
    def create_asset(name, attributes={})
      attributes = 
      create_record :asset, name.symbolize, {
        :title => name,
        :asset_file_name =>  'asset.jpg',
        :asset_content_type =>  'image/jpeg',
        :asset_file_size => '46248',
        :original_height => 200,
        :original_width => 400,
        :uuid => UUIDTools::UUID.timestamp_create.to_s
      }.merge(attributes)
      if @current_page_id
        create_record :page_attachment, "#{name}_attachment".symbolize, {
          :page_id => @current_page_id,
          :asset_id => asset_id(name.symbolize)
        }
      end
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-clipped-extension-1.0.1 spec/datasets/assets_dataset.rb
radiant-clipped-extension-1.0.0 spec/datasets/assets_dataset.rb