Permalink
Browse files

add failing test for using on nested unexisting properties

  • Loading branch information...
1 parent 08ae438 commit f0372f82053bcf3301fcd32b78890b12a7431bc3 @aheckmann aheckmann committed Mar 30, 2011
Showing with 38 additions and 2 deletions.
  1. +38 −2 test/model.test.js
View
@@ -2777,7 +2777,11 @@ module.exports = {
t.nest.toObject().should.eql({ st: "jsconf rules" });
t.nest.st.should.eql("jsconf rules");
- db.close();
+ t.save(function (err) {
+ should.strictEqual(err, null);
+ db.close();
+ })
+
},
'nested object property access works when root initd with undefined': function () {
@@ -2799,7 +2803,39 @@ module.exports = {
t.nest.toObject().should.eql({ st: "jsconf rules" });
t.nest.st.should.eql("jsconf rules");
- db.close();
+ t.save(function (err) {
+ should.strictEqual(err, null);
+ db.close();
+ })
+ },
+
+ 're-saving existing object with existing null nested object works': function(){
+ var db = start()
+
+ var schema = new Schema({
+ nest: {
+ st: String
+ }
+ });
+
+ mongoose.model('NestedStringC', schema);
+ var T = db.model('NestedStringC', collection);
+
+ var t = new T({ nest: null });
+
+ t.save(function (err) {
+ should.strictEqual(err, null);
+ t.nest = { st: "jsconf rules" };
+ t.save(function (err) {
+ should.strictEqual(err, null);
+
+ T.findById(t.id, function (err, t) {
+ should.strictEqual(err, null);
+ t.nest.st.should.eql("jsconf rules");
+ db.close();
+ })
+ })
+ })
}
};

0 comments on commit f0372f8

Please sign in to comment.