Sha256: 9a79af62d1eca6b9011eab0dcf7948ac74c5414f68b380e90212cc648f81bef5

Contents?: true

Size: 962 Bytes

Versions: 1

Compression:

Stored size: 962 Bytes

Contents

require 'test/helper'

class Photo
  include Thumbo
  def self.thumbo_storage
    @thumbo_storage ||= Thumbo::Filesystem.new(:path => 'tmp', :prefix_size => 2)
  end

  def self.thumbo_common
    {:common => 200}
  end

  def self.thumbo_square
    {:square => 50}
  end

  def thumbo_filename thumbo
    "#{self.object_id}_#{thumbo.title}.#{thumbo.fileext}"
  end

  def thumbo_uri thumbo
    first, last = thumbo.filename.split('_')
    "http://img.godfat.org/photos/#{first}_zzz_#{last}"
  end

  def thumbo_default_fileext
    'png'
  end

end

class StorageTest < MiniTest::Unit::TestCase
  def test_uri
    p = Photo.new
    t = p.thumbos[:original]
    t.from_blob(File.open('test/ruby.png').read)

    assert_equal( "http://img.godfat.org/photos/#{p.object_id}_zzz_original.png",
                  p.thumbos[:original].uri )
  end

  def test_raises
    assert_raises(Thumbo::FileNotFound) do
      Photo.new.thumbos[:original].delete
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
godfat-thumbo-0.5.0 test/test_storage.rb