it("should call callback with insertRec's err and first record", function(done) { insertRec.yields("error", insertRecords); setUpdate.yields(); SM.createQuestion(req, res, user, setID, function(err, record) { err.should.eql("error"); record.should.eql(insertRecords[0]); done(); }); });
it("should call update on the sets collection to add the new question to the end of the questions list", function(done) { insertRec.yields(null, insertRecords); setUpdate.yields(); SM.createQuestion(req, res, user, setID, function(err, record) { setUpdate.callCount.should.eql(1); var args = setUpdate.getCall(0).args; args[0].should.eql({_id: DB.getObjID(setID)}); args[1].should.eql({ $push: {question: insertRecords[0]._id} }); done(); }); });
it("should call insertRec to create a new question", function(done) { insertRec.yields(null, insertRecords); setUpdate.yields(); SM.createQuestion(req, res, user, setID, function(err, record) { insertRec.callCount.should.eql(1); var args = insertRec.getCall(0).args; args[0].should.eql(SM.questions); args[1].should.eql({type: "qtype", authorID: "user-id", setID: DB.getObjID(setID)}); done(); }); });
app.post('/question/create', function(request, response) { feed.createQuestion(request,response); })