IZ MS more photo controller specs

This commit is contained in:
zhitomirskiyi 2010-11-03 12:21:32 -07:00
parent 5e9d70f88c
commit 3578daa14e
3 changed files with 28 additions and 12 deletions

View file

@ -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
@ -106,7 +110,7 @@ class PhotosController < ApplicationController
@photo = current_user.find_visible_post_by_id params[:id]
@album = @photo.album
redirect_to @photo unless current_user.owns? @album
redirect_to @photo #unless current_user.owns? @photo
end
def update

View file

@ -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

View file

@ -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