Skip to content
Extraits de code Groupes Projets
Valider 24f8b33f rédigé par ilya's avatar ilya
Parcourir les fichiers

Tests all pass!

parent 07767e62
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -36,4 +36,7 @@ class Album
photos.each{|p| p.destroy}
end
def propagate_retraction
Retraction.for(self).notify_people
end
end
......@@ -14,9 +14,15 @@ class Photo < Post
validates_presence_of :album
def self.instantiate params = {}
image_file = params[:image]
params.delete :image
photo = Photo.new(params)
photo.image.store! image_file
photo
end
def remote_photo
puts image.url
User.owner.url.chop + image.url
end
......
......@@ -10,7 +10,7 @@ class ImageUploader < CarrierWave::Uploader::Base
def extension_white_list
%w(jpg jpeg gif png)
end
version :thumb_small do
process :resize_to_fill => [30,30]
end
......
......@@ -24,16 +24,16 @@ describe Album do
it 'should contain photos' do
album = Album.create(:name => "test collection")
photo = Photo.new(:person => @user)
photo = Factory.build(:photo, :person => @user)
album.photos << photo
album.photos.count.should == 1
end
it 'should remove all photos on album delete' do
photo_one = Photo.create(:person => @user, :album => @album, :created_at => Time.now)
photo_two = Photo.create(:person => @user, :album => @album, :created_at => Time.now-1)
photo_three = Photo.create(:person => @user, :album => @album, :created_at => Time.now-2)
photo_one = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now)
photo_two = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now-1)
photo_three = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now-2)
@album.photos += [photo_one, photo_two, photo_three]
......@@ -45,9 +45,9 @@ describe Album do
describe 'traversing' do
before do
@album = Album.create(:name => "test collection")
@photo_one = Photo.create(:person => @user, :album => @album, :created_at => Time.now)
@photo_two = Photo.create(:person => @user, :album => @album, :created_at => Time.now+1)
@photo_three = Photo.create(:person => @user, :album => @album, :created_at => Time.now+2)
@photo_one = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now)
@photo_two = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now+1)
@photo_three = Factory.create(:photo, :person => @user, :album => @album, :created_at => Time.now+2)
@album.photos += [@photo_one, @photo_two, @photo_three]
end
......@@ -76,9 +76,6 @@ describe Album do
@album.person = @user
@album.save
@xml = @album.to_xml.to_s
@photo_one = Photo.create(:person => @user, :album => @album, :created_at => Time.now)
@photo_two = Photo.create(:person => @user, :album => @album, :created_at => Time.now+1)
@photo_three = Photo.create(:person => @user, :album => @album, :created_at => Time.now+2)
end
it 'should have a person' do
@xml.include?(@album.person.id.to_s).should be true
......
......@@ -5,8 +5,16 @@ describe Photo do
@user = Factory.create(:user)
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
@fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml'
@photo = Photo.new(:person => @user, :album => Album.create(:name => "foo", :person => @user))
@album = Album.create(:name => "foo", :person => @user)
@photo = Photo.new(:person => @user, :album => @album)
end
it 'should have a constructor' do
photo = Photo.instantiate(:person => @user, :album => @album, :image => File.open(@fixture_name))
photo.save.should be true
photo.image.read.nil?.should be false
end
it 'should save a @photo to GridFS' do
file = File.open(@fixture_name)
@photo.image = file
......@@ -60,9 +68,9 @@ describe Photo do
end
it 'should save a signed @photo to GridFS' do
@photo.image = File.open(@fixture_name)
@photo.save.should == true
@photo.verify_creator_signature.should be true
photo = Photo.instantiate(:person => @user, :album => @album, :image => File.open(@fixture_name))
photo.save.should == true
photo.verify_creator_signature.should be true
end
end
......@@ -70,21 +78,15 @@ describe Photo do
describe 'remote photos' do
it 'should write the url on serialization' do
@photo.image = File.open(@fixture_name)
@photo.image.store!
@photo.save
xml = @photo.to_xml.to_s
xml.include?(@photo.image.url).should be true
remote_photo = Photo.from_xml xml
@photo.destroy
remote_photo.image.read.nil?.should be false
end
it 'should have an album id on serialization' do
@photo.image = File.open(@fixture_name)
xml = @photo.to_xml.to_s
xml.include?(@photo.album.id.to_s).should be true
remote_photo = Photo.from_xml xml
@photo.destroy
remote_photo.save.should be true
remote_photo.album.nil?.should be false
end
end
end
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter