Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
5e9d70f88c
1 changed files with 67 additions and 15 deletions
|
|
@ -5,34 +5,86 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe PhotosController do
|
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
|
before do
|
||||||
@user = make_user
|
friend_users(user, aspect, user2, aspect2)
|
||||||
@aspect = @user.aspects.create(:name => "lame-os")
|
sign_in :user, user
|
||||||
@album = @user.post :album, :to => @aspect.id, :name => 'things on fire'
|
user.reload
|
||||||
@fixture_filename = 'button.png'
|
@controller.stub!(:current_user).and_return(user)
|
||||||
@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
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create' do
|
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
|
end
|
||||||
|
|
||||||
describe "#update" do
|
describe "#update" do
|
||||||
it "should update the caption of a photo" do
|
it "should update the caption of a photo" do
|
||||||
put :update, :id => @photo.id, :photo => { :caption => "now with lasers!"}
|
put :update, :id => photo.id, :photo => { :caption => "now with lasers!"}
|
||||||
@photo.reload.caption.should == "now with lasers!"
|
photo.reload.caption.should == "now with lasers!"
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't overwrite random attributes" do
|
it "doesn't overwrite random attributes" do
|
||||||
new_user = Factory.create :user
|
new_user = Factory.create :user
|
||||||
params = { :caption => "now with lasers!", :person_id => new_user.id}
|
params = { :caption => "now with lasers!", :person_id => new_user.id}
|
||||||
put :update, :id => @photo.id, :photo => params
|
put :update, :id => photo.id, :photo => params
|
||||||
@photo.reload.person_id.should == @user.person.id
|
photo.reload.person_id.should == user.person.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue