Sha256: fced41f862e2b967ef78ad7d09fc468c854e9a35a2f4d5462a1cc66f74c3f14d

Contents?: true

Size: 1.94 KB

Versions: 17

Compression:

Stored size: 1.94 KB

Contents

require File.expand_path('../../spec_helper', __FILE__)

describe Asset do
  dataset :assets

  # these are here to check that paperclip and our various add-ons are all working together.
  # most of the components are also tested individually but in more abstract ways.

  let(:asset) {
    asset = assets(:test1)
    asset.asset = File.new(File.join(File.dirname(__FILE__), "..", "fixtures", "5k.png"))
    asset
  }
  
  describe "on assigning a file to an asset" do
    before do
      TrustyCms.config["assets.create_image_thumbnails?"] = true
      TrustyCms.config["assets.thumbnails.configured"] = "special:size=800x800>,format=jpg|tiny:size=#10x10,format=png"
    end
  
    it "should have saved the asset" do
      asset.new_record?.should be_false
    end

    it "should have calculated asset type" do
      asset.asset_type.should == AssetType[:image]
    end

    it "should have recorded width and height and original extension" do
      asset.original_width.should == 434
      asset.original_height.should == 66
      asset.original_extension.should == 'png'
    end

    it "should respond to original geometry" do
      asset.original_geometry.should == Paperclip::Geometry.new(434,66)
    end

    it "should calculate thumbnail geometry" do
      original_geometry = Paperclip::Geometry.new(434,66)
      asset.geometry.should == original_geometry
      asset.geometry(:icon).should == original_geometry * Paperclip::Geometry.parse("42x42#")
    end

    it "should respond to image dimension methods" do
      asset.width.should == 434
      asset.height.should == 66
      asset.width(:icon).should == 42
      asset.height(:icon).should == 42
    end

    it "should respond to image shape methods" do
      asset.horizontal?.should be_true
      asset.vertical?.should be_false
      asset.square?.should be_false
      asset.square?(:icon).should be_true
      asset.orientation.should == 'horizontal'
      asset.aspect.should == 434.0/66.0
    end

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
trusty-clipped-extension-2.0.2.pre.beta spec/models/post_processing_spec.rb
trusty-clipped-extension-2.0.1.pre.beta spec/models/post_processing_spec.rb
trusty-clipped-extension-2.0.0.pre.beta spec/models/post_processing_spec.rb
trusty-clipped-extension-1.1.1 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.1.0 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.11 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.10 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.9 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.8 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.7 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.6 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.5 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.4 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.3 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.2 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.1 spec/models/post_processing_spec.rb
trusty-clipped-extension-1.0.0 spec/models/post_processing_spec.rb