mirror of
https://github.com/fergalmoran/roboto-promoto.git
synced 2025-12-22 09:37:37 +00:00
Fixed search test in promotion
This commit is contained in:
@@ -12,11 +12,5 @@ var PromotionSchema = new Schema({
|
||||
|
||||
/* Indexes */
|
||||
PromotionSchema.index({title: 1, user: 1}, {unique: true});
|
||||
var _model = mongoose.model('Promotion', PromotionSchema);
|
||||
|
||||
/* Operations */
|
||||
PromotionSchema.statics.findByTitle = function(title, cb){
|
||||
console.log("findByTitle: " + title);
|
||||
_model.findOne({title: title}, cb);
|
||||
};
|
||||
|
||||
mongoose.model('Promotion', PromotionSchema);
|
||||
|
||||
@@ -75,8 +75,9 @@ describe('Promotion Model', function() {
|
||||
});
|
||||
describe('Search methods', function () {
|
||||
it('should find promotion by title', function (done) {
|
||||
Promotion.findByTitle('Test Prom 1', function(result){
|
||||
Promotion.findOne({title: 'Test Prom 1', user: user}, function (err, result) {
|
||||
should.exist(result);
|
||||
should.not.exist(err);
|
||||
result.title.should.equal('Test Prom 1');
|
||||
done();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user