Skip to content

Instantly share code, notes, and snippets.

@mariovisic
Created June 27, 2011 04:15
Show Gist options
  • Select an option

  • Save mariovisic/1048307 to your computer and use it in GitHub Desktop.

Select an option

Save mariovisic/1048307 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe AvatarUploader do
let(:avatar_uploader) { AvatarUploader.new(outing, :avatar) }
let(:location) { Factory.build(:location, :id => 123) }
let(:user) { Factory.build(:user, :id => 103) }
let(:outing) { Factory.build(:outing, :id => 101, :image_token => 'image_token') }
before :all do
AvatarUploader.enable_processing = true
AvatarUploader.versions.each do |key, version|
version.enable_processing = true
end
avatar_uploader.store!(File.open("#{Rails.root}/spec/support/assets/avatar.jpg"))
end
after :all do
avatar_uploader.remove!
AvatarUploader.enable_processing = false
end
context 'the image' do
it 'should be resized to 640 square' do
avatar_uploader.should have_dimensions(640, 640)
end
it 'should be present in the correct folder' do
# Avatars have hashes created for their filenames
avatar_uploader.path.should include '/a/image_token.jpg'
end
end
context 'a thumbnail' do
it 'should be created with dimensions of 120 square' do
avatar_uploader.thumb.should have_dimensions(120, 120)
end
it 'should be present in the correct folder' do
# Avatars have hashes created for their filenames
avatar_uploader.thumb.path.should include '/a/thumb_image_token.jpg'
end
end
context 'a small copy' do
it 'should be created with dimensions of 320 square' do
avatar_uploader.small.should have_dimensions(320, 320)
end
it 'should be present in the correct folder' do
# Avatars have hashes created for their filenames
avatar_uploader.small.path.should include '/a/small_image_token.jpg'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment