DG MS; fixed most photo specs
This commit is contained in:
parent
4827953bec
commit
dae8f26692
2 changed files with 12 additions and 9 deletions
|
|
@ -14,8 +14,9 @@ class User
|
||||||
before_validation :do_bad_things
|
before_validation :do_bad_things
|
||||||
|
|
||||||
|
|
||||||
|
def method_missing(method, *args)
|
||||||
|
self.person.send(method, *args)
|
||||||
|
end
|
||||||
|
|
||||||
def pending_friends
|
def pending_friends
|
||||||
Person.all(:id => self.pending_friend_ids)
|
Person.all(:id => self.pending_friend_ids)
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,19 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
describe Photo do
|
describe Photo do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
|
@user.person.save
|
||||||
|
|
||||||
@fixture_filename = 'bp.jpeg'
|
@fixture_filename = 'bp.jpeg'
|
||||||
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
|
@fixture_name = File.dirname(__FILE__) + '/../fixtures/bp.jpeg'
|
||||||
@fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml'
|
@fail_fixture_name = File.dirname(__FILE__) + '/../fixtures/msg.xml'
|
||||||
@album = Album.create(:name => "foo", :person => @user)
|
@album = Album.create(:name => "foo", :person => @user.person)
|
||||||
@photo = Photo.new(:person => @user, :album => @album)
|
@photo = Photo.new(:person => @user.person, :album => @album)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have a constructor' do
|
it 'should have a constructor' do
|
||||||
image = File.open(@fixture_name)
|
image = File.open(@fixture_name)
|
||||||
photo = Photo.instantiate(:person => @user, :album => @album, :user_file => [image])
|
photo = Photo.instantiate(:person => @user.person, :album => @album, :user_file => [image])
|
||||||
photo.created_at.nil?.should be false
|
photo.created_at.nil?.should be false
|
||||||
|
|
||||||
photo.image.read.nil?.should be false
|
photo.image.read.nil?.should be false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -27,11 +28,11 @@ describe Photo do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'must have an album' do
|
it 'must have an album' do
|
||||||
photo = Photo.new(:person => @user)
|
photo = Photo.new(:person => @user.person)
|
||||||
photo.image = File.open(@fixture_name)
|
photo.image = File.open(@fixture_name)
|
||||||
photo.save
|
photo.save
|
||||||
photo.valid?.should be false
|
photo.valid?.should be false
|
||||||
photo.album = Album.create(:name => "foo", :person => @user)
|
photo.album = Album.create(:name => "foo", :person => @user.person)
|
||||||
photo.save
|
photo.save
|
||||||
Photo.first.album.name.should == 'foo'
|
Photo.first.album.name.should == 'foo'
|
||||||
end
|
end
|
||||||
|
|
@ -49,6 +50,7 @@ describe Photo do
|
||||||
|
|
||||||
@user.profile.image_url = @photo.image.url(:thumb_medium)
|
@user.profile.image_url = @photo.image.url(:thumb_medium)
|
||||||
@user.save
|
@user.save
|
||||||
|
@user.person.save
|
||||||
|
|
||||||
User.first.profile.image_url.should == @photo.image.url(:thumb_medium)
|
User.first.profile.image_url.should == @photo.image.url(:thumb_medium)
|
||||||
@photo.destroy
|
@photo.destroy
|
||||||
|
|
@ -91,7 +93,7 @@ describe Photo do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should save a signed @photo to GridFS' do
|
it 'should save a signed @photo to GridFS' do
|
||||||
photo = Photo.create(:person => @user, :album => @album, :image => File.open(@fixture_name))
|
photo = Photo.create(:person => @user.person, :album => @album, :image => File.open(@fixture_name))
|
||||||
photo.save.should == true
|
photo.save.should == true
|
||||||
photo.verify_creator_signature.should be true
|
photo.verify_creator_signature.should be true
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue