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

Added spec for remote photo url setting to photos

parent 4019e442
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -30,7 +30,8 @@ class Photo < Post
validates_true_for :album_id, :logic => lambda {self.validate_album_person}
before_destroy :ensure_user_picture
key :remote_photo_path
key :remote_photo_name
def validate_album_person
album.person_id == person_id
......@@ -42,15 +43,13 @@ class Photo < Post
def remote_photo= remote_path
name_start = remote_path.rindex '/'
@remote_photo_path = remote_path.slice(0, name_start )
@remote_photo_name = remote_path.slice(name_start, remote_path.length)
save
raise "Failed to set path for : #{self.inspect}" if Photo.first(:id => self.id).url.nil?
self.remote_photo_path = remote_path.slice(0, name_start )
self.remote_photo_name = remote_path.slice(name_start, remote_path.length)
end
def url name = nil
if @remote_photo_path
@remote_photo_path + name.to_s + @remote_photo_name
def url(name = nil)
if remote_photo_path
person.url.chop + remote_photo_path + name.to_s + remote_photo_name
else
image.url name
end
......
......@@ -108,5 +108,21 @@ describe Photo do
xml = @photo.to_xml.to_s
xml.include?(@photo.album_id.to_s).should be true
end
it 'should set the remote_photo on marshalling' do
@photo.image.store! File.open(@fixture_name)
@photo.save
@photo.reload
xml = @photo.to_diaspora_xml
id = @photo.id
@photo.destroy
@user.receive xml
new_photo = Photo.first(:id => id)
new_photo.url.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