Merge pull request #576 from fabien/fix/scope-caching
Don't cache static scope method results
This commit is contained in:
commit
014e91ea0c
|
@ -52,7 +52,7 @@ ScopeDefinition.prototype.related = function(receiver, scopeParams, condOrRefres
|
|||
|
||||
var actualCond = {};
|
||||
var actualRefresh = false;
|
||||
var saveOnCache = true;
|
||||
var saveOnCache = receiver instanceof DefaultModelBaseClass;
|
||||
if (typeof condOrRefresh === 'function' &&
|
||||
options === undefined && cb === undefined) {
|
||||
// related(receiver, scopeParams, cb)
|
||||
|
|
|
@ -76,6 +76,28 @@ describe('scope', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('should not cache any results', function (done) {
|
||||
Station.scope('active', {where: {isActive: true}});
|
||||
Station.active.create(function (err, s) {
|
||||
if (err) return done(err);
|
||||
s.isActive.should.be.true;
|
||||
Station.active(function(err, ss) {
|
||||
if (err) return done(err);
|
||||
ss.should.have.lengthOf(1);
|
||||
ss[0].id.should.eql(s.id);
|
||||
s.updateAttribute('isActive', false, function(err, s) {
|
||||
if (err) return done(err);
|
||||
s.isActive.should.be.false;
|
||||
Station.active(function(err, ss) {
|
||||
if (err) return done(err);
|
||||
ss.should.have.lengthOf(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('scope - order', function () {
|
||||
|
|
Loading…
Reference in New Issue