2013-06-16 04:39:48 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe OptimizedImage do
|
|
|
|
|
|
|
|
it { should belong_to :upload }
|
|
|
|
|
2013-06-16 20:46:42 -04:00
|
|
|
let(:upload) { build(:upload) }
|
|
|
|
let(:oi) { OptimizedImage.create_for(upload, 100, 100) }
|
|
|
|
|
|
|
|
describe ".create_for" do
|
|
|
|
|
|
|
|
before(:each) do
|
2013-07-07 19:39:08 -04:00
|
|
|
ImageSorcery.any_instance.expects(:convert).returns(true)
|
2013-06-16 20:46:42 -04:00
|
|
|
# make sure we don't hit the filesystem
|
|
|
|
FileUtils.stubs(:mkdir_p)
|
|
|
|
File.stubs(:open)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "works" do
|
2013-07-07 19:39:08 -04:00
|
|
|
Tempfile.any_instance.expects(:close)
|
|
|
|
Tempfile.any_instance.expects(:unlink)
|
2013-06-16 22:02:17 -04:00
|
|
|
oi.sha1.should == "da39a3ee5e6b4b0d3255bfef95601890afd80709"
|
|
|
|
oi.extension.should == ".jpg"
|
2013-07-07 19:39:08 -04:00
|
|
|
oi.width.should == 100
|
|
|
|
oi.height.should == 100
|
2013-06-16 20:46:42 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2013-06-16 04:39:48 -04:00
|
|
|
end
|