add support for user._tmp, disable user.filters since it is not used
This commit is contained in:
@@ -72,10 +72,11 @@ describe('Base model plugin', () => {
|
||||
schema.plugin(baseModel, options);
|
||||
|
||||
let objToTransform = {ok: true, amPrivate: true};
|
||||
let privatized = schema.options.toJSON.transform({}, objToTransform);
|
||||
let doc = {doc: true};
|
||||
let privatized = schema.options.toJSON.transform(doc, objToTransform);
|
||||
|
||||
expect(privatized).to.equals(true);
|
||||
expect(options.toJSONTransform).to.be.calledWith(objToTransform);
|
||||
expect(options.toJSONTransform).to.be.calledWith(objToTransform, doc);
|
||||
});
|
||||
|
||||
it('accepts a transform function for sanitize', () => {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import { model as User } from '../../../../../website/src/models/user';
|
||||
|
||||
describe('User Model', () => {
|
||||
it('keeps user._tmp when calling .toJSON', () => {
|
||||
let user = new User({
|
||||
auth: {
|
||||
local: {
|
||||
username: 'username',
|
||||
lowerCaseUsername: 'username',
|
||||
email: 'email@email.email',
|
||||
salt: 'salt',
|
||||
hashed_password: 'hashed_password', // eslint-disable-line camelcase
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
user._tmp = {ok: true};
|
||||
user._nonTmp = {ok: true};
|
||||
|
||||
expect(user._tmp).to.eql({ok: true});
|
||||
expect(user._nonTmp).to.eql({ok: true});
|
||||
|
||||
let toObject = user.toObject();
|
||||
let toJSON = user.toJSON();
|
||||
|
||||
expect(toObject).to.not.have.keys('_tmp');
|
||||
expect(toObject).to.not.have.keys('_nonTmp');
|
||||
|
||||
expect(toJSON).to.have.any.key('_tmp');
|
||||
expect(toJSON._tmp).to.eql({ok: true});
|
||||
expect(toJSON).to.not.have.keys('_nonTmp');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user