Sha256: 57821c97ab5c56b4d88b9901e253a65441e273d1b6603be26665d4f27152d986

Contents?: true

Size: 1.68 KB

Versions: 2

Compression:

Stored size: 1.68 KB

Contents

require 'spec/spec_helper'

describe ShopProductAttachment do
  dataset :shop_products
  
  context 'attributes' do
  
    before(:each) do
      @product_image = shop_products(:soft_bread).attachments.first
    end
      
    it 'should have a product id' do
      @product_image.shop_product_id.should === shop_products(:soft_bread).id
    end
    
    it 'should have an image id' do
      @product_image.image_id.should === images(:soft_bread_front).id
    end
    
    it 'should have a position' do
      @product_image.position.should === 1
    end
    
    it 'should have a product' do
      @product_image.product.class.should == ShopProduct
    end
    
    it 'should have an image' do
      @product_image.image.class.should == Image
    end
    
  end
  
  context 'alias methods' do
    
    before(:each) do
      @product_image = shop_products(:soft_bread).attachments.first
    end
    
    describe '#url' do
      it 'should return its assets url' do
        @product_image.url.should === @product_image.image.url
      end
    end
    describe '#title' do
      it 'should return its assets title' do
        @product_image.title.should === @product_image.image.title
      end
    end
    describe '#caption' do
      it 'should return its assets caption' do
        @product_image.caption.should === @product_image.image.caption
      end
    end
  end
  
  context 'class methods' do
    describe '#params' do
      it 'should have a set of standard parameters' do
        ShopProductAttachment.params.should === [
          :id,
          :title,
          :caption,
          :image_file_name,
          :image_content_type,
          :image_file_size
        ]
      end
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-shop-extension-0.9.3 spec/models/shop_product_attachment_spec.rb
radiant-shop-extension-0.9.2 spec/models/shop_product_attachment_spec.rb