blob: 892cccd086311ae51782b7814114cec7bb4193ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe ProfilePhoto, "when constructing a new photo" do
before do
@mock_user = mock_model(User)
end
it 'should take no image as invalid' do
profile_photo = ProfilePhoto.new(:data => nil, :user => @mock_user)
profile_photo.valid?.should == false
end
it 'should take bad binary data as invalid' do
profile_photo = ProfilePhoto.new(:data => 'blahblahblah', :user => @mock_user)
profile_photo.valid?.should == false
end
it 'should accept and convert a PNG to right size' do
data = load_file_fixture("parrot.png")
profile_photo = ProfilePhoto.new(:data => data, :user => @mock_user)
profile_photo.valid?.should == true
profile_photo.image.format.should == 'PNG'
profile_photo.image.columns.should == 96
profile_photo.image.rows.should == 96
end
it 'should accept and convert a JPEG to right format and size' do
data = load_file_fixture("parrot.jpg")
profile_photo = ProfilePhoto.new(:data => data, :user => @mock_user)
profile_photo.valid?.should == true
profile_photo.image.format.should == 'PNG'
profile_photo.image.columns.should == 96
profile_photo.image.rows.should == 96
end
it 'should accept a draft PNG and not resize it' do
data = load_file_fixture("parrot.png")
profile_photo = ProfilePhoto.new(:data => data, :draft => true)
profile_photo.valid?.should == true
profile_photo.image.format.should == 'PNG'
profile_photo.image.columns.should == 198
profile_photo.image.rows.should == 289
end
end
|