Skip to content
Extraits de code Groupes Projets
Valider 3578daa1 rédigé par zhitomirskiyi's avatar zhitomirskiyi
Parcourir les fichiers

IZ MS more photo controller specs

parent 5e9d70f8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -10,7 +10,7 @@ class PhotosController < ApplicationController
def index
if params[:person_id]
@person = current_user.visible_people.find_by_person_id(params[:person_id])
@person = current_user.contact_for_person_id(params[:person_id]).person
end
@person ||= current_user.person
......@@ -87,6 +87,10 @@ class PhotosController < ApplicationController
@photo.destroy
flash[:notice] = I18n.t 'photos.destroy.notice'
redirect = @photo.album
redirect ||= photos_path
respond_with :location => @photo.album
end
......@@ -104,9 +108,9 @@ class PhotosController < ApplicationController
def edit
@photo = current_user.find_visible_post_by_id params[:id]
@album = @photo.album
@album = @photo.album
redirect_to @photo unless current_user.owns? @album
redirect_to @photo #unless current_user.owns? @photo
end
def update
......
......@@ -127,10 +127,6 @@ module Diaspora
aspect.save
end
def contact_for(person)
friends.first(:person_id => person.id)
end
def request_from_me?(request)
request.callback_url == person.receive_url
end
......
......@@ -16,6 +16,7 @@ describe PhotosController do
let(:fixture_name) {File.join(File.dirname(__FILE__), '..', 'fixtures', filename)}
let(:image) {File.open(fixture_name)}
let!(:photo){ user.post(:photo, :album_id => album.id, :user_file => image, :to => aspect.id)}
let(:photo_no_album){ user.post(:photo, :user_file => image, :to => aspect.id)}
before do
friend_users(user, aspect, user2, aspect2)
......@@ -36,7 +37,6 @@ describe PhotosController do
describe '#index' do
it 'defaults to returning all of users pictures' do
pending
get :index
assigns[:person].should == user.person
assigns[:photos].should == [photo]
......@@ -44,12 +44,9 @@ describe PhotosController do
end
it 'sets the person to a friend if person_id is set' do
pending
puts user.visible_people.inspect
user.should_not_receive(:person)
get :index, :person_id => user2.person.id
assigns[:person].should == [user2.person]
assigns[:person].should == user2.person
assigns[:photos].should == []
assigns[:albums].should == []
end
......@@ -62,11 +59,30 @@ describe PhotosController do
end
describe '#show' do
it 'assigns the photo based on the photo id' do
get :show, :id => photo.id
assigns[:photo].should == photo
assigns[:album].should == album
assigns[:ownership].should == true
end
end
describe '#edit' do
it 'should let you edit a photo with an album' do
pending
get :edit, :id => photo.id
response.should_not redirect_to(photo)
end
it 'should let you edit a photo you own that does not have an album' do
pending
get :edit, :id => photo_no_album.id
response.should_not redirect_to(photo)
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