Skip to content

Commit

Permalink
Added some tests for a possible bug in ObjectID handling
Browse files Browse the repository at this point in the history
  • Loading branch information
notheotherben committed May 4, 2014
1 parent 4ded748 commit 80e0fe5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/bugs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var config = require('./config.js');
var Database = require('../index.js');
var Model = Database.Model;
var Instance = Database.Instance;
var should = require('should');
var Concoction = require('concoction');

describe('bugs', function () {
"use strict";
var db = null;

before(function (done) {
db = new Database(config);
db.connect(done);
});

it("shouldn't attempt to change an ObjectID when saving an instance", function(done) {
var model = new Model(db, 'model', {
id: false,
data: [String]
}, {

});

model.remove(function(err) {
if(err) return done(err);

model.create({ data: ['testing'] }, function(err, instance) {
if(err) return done(err);
should.exist(instance);

instance.data.push('tested');
instance.save(function(err) {
should.not.exist(err);
instance.data.should.eql(['testing', 'tested']);
done();
});
});
});
});
});

0 comments on commit 80e0fe5

Please sign in to comment.