var PhotoFactory = Factories.photo,
    UserFactory = Factories.user;

describe('Photo', function () {
    //this has been tested because createdAt is not done automatically for photos (see photo class)
    describe('createdAt', function () {
        it('is set after creating date', function () {
            var date = new Date(); //The date when ~ the photo is created
            var promise = PhotoFactory.basic();

            return promise.then(function (photo) {
                photo.createdAt.should.be.approximately(date, 1000);
            });
        });

        it('is not changed after update', function () {
            var promise = PhotoFactory.basic();

            return promise.then(function (photo) {
                //Change property of photo
                photo.description = 'new description';

                //Save photo, and ensure createdAt isn't changed
                return photo.save().then(function (updatedPhoto) {
                    photo.createdAt.should.equal(updatedPhoto.createdAt).and.not.equal(null);
                });
            });
        });
    });

    describe('user', function () {
        it('allows the setting of user', function () {
            //Create test objects to use
            var promise = q.all([
                UserFactory.basic(),
                PhotoFactory.basic()
            ]);

            return promise.spread(function (user, photo) {
                return photo.setUser(user).then(function () {
                    //Ensure relationship was established
                    return photo.getUser().then(function (userFound) {
                        userFound.id.should.equal(user.id);
                    });
                });
            });
        });
    });

    describe('uploadSave', function () {
        it('creates a thumbnail version of the file', function () {
            return PhotoFactory.basic().then(function (photo) {
                photo.setPhotoByPath(system.pathTo('test/unit/fixtures/models/photo/image.png'));

                //Perform image upload
                return photo.uploadSave().then(function () {
                    //Ensure thumbnail was added
                    photo.id.should.be.a.Number;
                    photo.imagePath.should.equal('/photos/' + photo.id + '.png');
                    photo.thumbnailPath.should.equal('/photos/thumbnail/' + photo.id + '.png');
                });
            });
        });

//        it('notifies followers of the photo upload', function (done) {
//            //TODO fix & restore test
//            q.all([
//                    //Create test users
//                    UserFactory.basic(),
//                    UserFactory.basic()
//                ])
//                .spread(function (user, follower) {
//                    //Simulate following of followee
//                    user.addFollower(follower).then(function (follower) {
//                        //Create test photo
//                        PhotoFactory.basic({userID: user.id}).then(function (photo) {
//                            photo.setPhotoByPath(system.pathTo('test/unit/fixtures/models/photo/image.png'));
//
//                            //Perform image upload
//                            photo.uploadSave().then(function () {
//                                //Get followee's feed
//                                follower.getFeedItems().then(function (feedPhotos) {
//                                    feedPhotos.length.should.equal(1, done);
//                                    done();
//                                });
//                            })
//                        });
//                    });
//                });
//        });
    })
});
@@ -3721,11 +3721,2354 @@
 %0A    %7D)%0A
-%7D);
+    %0A    // processPhotoUpload UNIT TESTS%0A    describe('processPhotoUpload', function()%7B%0A%0A        // Successfully creates image and thumbnail and write%0A        //      correct paths to database%0A        it('creates versions of file upload and writes paths to db',function()%7B%0A%0A            return PhotoFactory.basic().then(function (photo) %7B%0A%0A                // setup valid pre-requisites%0A                photo.setImageUpload(this._photoUpload);%0A                photo.setPhotoByPath(system.pathTo('test/unit/fixtures/models/photo/image.png'));%0A                photo.processPhotoUpload().then(function()%7B%0A%0A                    // Verify valid photo id and self reference%0A                    photo.id.should.be.a.Number;%0A%0A                    // Verify that photo paths are correctly added%0A                    photo.imagePath.should.equal('/photos/' + photo.id + '.png');%0A                    photo.thumbnailPath.should.equal('/photos/thumbnail/' + photo.id + '.png');%0A%0A                %7D);%0A%0A            %7D);%0A%0A        %7D);%0A%0A        // Pass a photo with invalid id, throws invalid id%0A        it('non-valid id',function()%7B%0A%0A            return PhotoFactory.basic().then(function (photo) %7B%0A%0A                // setup valid pre-requisites%0A                photo.setImageUpload(this._photoUpload);%0A                photo.setPhotoByPath(system.pathTo('test/unit/fixtures/models/photo/image.png'));%0A%0A                // Set photo id to invalid value%0A                photo.id = null;%0A%0A                // Call processPhotoUpload%0A                //  function should throw invalid id error%0A                photo.processPhotoUpload().should.throw(new Error('Invalid call - ID must be set'));%0A%0A            %7D);%0A%0A        %7D);%0A%0A        // Pass invalid photo, throws invalid photo%0A        it('invalid image',function()%7B%0A%0A            return PhotoFactory.basic().then(function (photo) %7B%0A                photo.setImageUpload(this._photoUpload);%0A                photo.setPhotoByPath(system.pathTo('test/unit/fixtures/models/photo/image.png'));%0A%0A                // Set photo to invalid%0A                this.photo = null;%0A%0A                // Call processPhotoUpload with invalid photo,%0A                //      should throw Error%0A                photo.processPhotoUpload().should.throw(Error('Invalid call - setImageUpload() must be called'));%0A%0A            %7D);%0A%0A        %7D);%0A%0A    %7D);%0A%7D);%0A

Update photo.js