2011-06-21 00:39:59 +00:00
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2011-11-20 11:47:41 +00:00
|
|
|
describe Locomotive::ContentAsset do
|
2011-06-21 00:39:59 +00:00
|
|
|
|
|
|
|
describe 'attaching a file' do
|
|
|
|
|
|
|
|
before(:each) do
|
2011-11-20 11:52:20 +00:00
|
|
|
Locomotive::ContentAsset.any_instance.stubs(:site_id).returns('test')
|
2011-08-25 21:28:56 +00:00
|
|
|
@asset = FactoryGirl.build(:asset)
|
2011-06-21 00:39:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should process picture' do
|
2011-11-20 11:52:20 +00:00
|
|
|
@asset.source = FixturedAsset.open('5k.png')
|
2011-06-21 00:39:59 +00:00
|
|
|
@asset.source.file.content_type.should_not be_nil
|
|
|
|
@asset.image?.should be_true
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should get width and height from the image' do
|
2011-11-20 11:52:20 +00:00
|
|
|
@asset.source = FixturedAsset.open('5k.png')
|
2011-06-21 00:39:59 +00:00
|
|
|
@asset.width.should == 32
|
|
|
|
@asset.height.should == 32
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'vignette' do
|
|
|
|
|
|
|
|
before(:each) do
|
2011-11-20 11:52:20 +00:00
|
|
|
@asset = FactoryGirl.build(:asset, :source => FixturedAsset.open('5k.png'))
|
2011-06-21 00:39:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not resize image smaller than 50x50' do
|
|
|
|
@asset.vignette_url.should =~ /^\/spec\/.*\/5k.png/
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has any possible resized versions' do
|
|
|
|
@asset.stubs(:with).returns(81)
|
|
|
|
@asset.stubs(:height).returns(81)
|
2011-06-28 13:38:13 +00:00
|
|
|
@asset.vignette_url.should =~ /^\/images\/dynamic\/.*\/5k.png/
|
2011-06-21 00:39:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2011-11-20 11:47:41 +00:00
|
|
|
end
|