diff --git a/spec/controllers/photos_controller_spec.rb b/spec/controllers/photos_controller_spec.rb index 00c838642..da6e1c885 100644 --- a/spec/controllers/photos_controller_spec.rb +++ b/spec/controllers/photos_controller_spec.rb @@ -5,34 +5,86 @@ require 'spec_helper' describe PhotosController do - render_views + let(:user) {make_user} + let(:user2) {make_user} + + let(:aspect) {user.aspects.create(:name => 'winners')} + let(:aspect2) {user2.aspects.create(:name => 'winners')} + + let!(:album) {user.post(:album, :to => aspect.id, :name => "room on fire")} + let(:filename) {'button.png'} + 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)} + before do - @user = make_user - @aspect = @user.aspects.create(:name => "lame-os") - @album = @user.post :album, :to => @aspect.id, :name => 'things on fire' - @fixture_filename = 'button.png' - @fixture_name = File.join(File.dirname(__FILE__), '..', 'fixtures', @fixture_filename) - image = File.open(@fixture_name) - #@photo = Photo.instantiate( - # :person => @user.person, :album => @album, :user_file => image) - @photo = @user.post(:photo, :album_id => @album.id, :user_file => image, :to => @aspect.id) - sign_in :user, @user + friend_users(user, aspect, user2, aspect2) + sign_in :user, user + user.reload + @controller.stub!(:current_user).and_return(user) end describe '#create' do + it 'can make a photo in an album' do + pending + end + + it 'can make a picture without an album' do + pending + end + end + + describe '#index' do + it 'defaults to returning all of users pictures' do + pending + get :index + assigns[:person].should == user.person + assigns[:photos].should == [photo] + assigns[:albums].should == [album] + 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[:photos].should == [] + assigns[:albums].should == [] + end + + it 'sets the aspect to photos?' do + get :index + assigns[:aspect].should == :photos + end + + end + + describe '#show' do + + end + + describe '#edit' do + + end + + + describe '#destroy' do + end describe "#update" do it "should update the caption of a photo" do - put :update, :id => @photo.id, :photo => { :caption => "now with lasers!"} - @photo.reload.caption.should == "now with lasers!" + put :update, :id => photo.id, :photo => { :caption => "now with lasers!"} + photo.reload.caption.should == "now with lasers!" end it "doesn't overwrite random attributes" do new_user = Factory.create :user params = { :caption => "now with lasers!", :person_id => new_user.id} - put :update, :id => @photo.id, :photo => params - @photo.reload.person_id.should == @user.person.id + put :update, :id => photo.id, :photo => params + photo.reload.person_id.should == user.person.id end end end