Merge branch 'dev' of http://git.verdnatura.es/salix into dev

This commit is contained in:
Carlos Jimenez 2018-10-03 12:55:10 +02:00
commit c1893be92a
6 changed files with 17 additions and 16 deletions

View File

@ -1,14 +1,16 @@
const app = require(`${servicesDir}/client/server/server`); const app = require(`${servicesDir}/client/server/server`);
describe('Client addressesPropagateRe', () => { describe('Client addressesPropagateRe', () => {
let client;
beforeEach(async() => { beforeEach(async() => {
client = await app.models.Client.findById(101);
await app.models.Address.update({clientFk: 101}, {isEqualizated: false}); await app.models.Address.update({clientFk: 101}, {isEqualizated: false});
await app.models.Client.update({id: 101}, {hasToInvoiceByAddress: true}); await client.updateAttributes({hasToInvoiceByAddress: true});
}); });
afterAll(async() => { afterAll(async() => {
await app.models.Address.update({clientFk: 101}, {isEqualizated: false}); await app.models.Address.update({clientFk: 101}, {isEqualizated: false});
await app.models.Client.update({id: 101}, {hasToInvoiceByAddress: true}); await client.updateAttributes({hasToInvoiceByAddress: true});
}); });
it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => { it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => {

View File

@ -32,10 +32,6 @@ describe('Client updateBasicData', () => {
let result = await app.models.Client.updateBasicData(validparams, id); let result = await app.models.Client.updateBasicData(validparams, id);
expect(result).toEqual({count: 1}); expect(result.email).toEqual('myNewEmail@myDomain.es');
let updatedClient = await app.models.Client.findById(101);
expect(updatedClient.email).toEqual('myNewEmail@myDomain.es');
}); });
}); });

View File

@ -50,10 +50,6 @@ describe('Client updateFiscalData', () => {
let result = await app.models.Client.updateFiscalData(ctxOfAdmin, validparams, idWithDataChecked); let result = await app.models.Client.updateFiscalData(ctxOfAdmin, validparams, idWithDataChecked);
expect(result).toEqual({count: 1}); expect(result.postcode).toEqual('12345');
let updatedClient = await app.models.Client.findById(idWithDataChecked);
expect(updatedClient.postcode).toEqual('12345');
}); });
}); });

View File

@ -43,7 +43,7 @@ module.exports = Self => {
if (validUpdateParams.indexOf(key) === -1) if (validUpdateParams.indexOf(key) === -1)
throw new UserError(`You don't have enough privileges to do that`); throw new UserError(`You don't have enough privileges to do that`);
} }
let client = await Self.app.models.Client.findById(id);
return await Self.app.models.Client.update({id: id}, params); return await client.updateAttributes(params);
}; };
}; };

View File

@ -61,6 +61,8 @@ module.exports = Self => {
} }
params.id = id; params.id = id;
return await Self.app.models.Client.update({id: id}, params);
let client = await Self.app.models.Client.findById(id);
return await client.updateAttributes(params);
}; };
}; };

View File

@ -125,8 +125,13 @@ module.exports = function(Self) {
Object.assign(newInstance, ctx.hookState.newInstance) Object.assign(newInstance, ctx.hookState.newInstance)
} }
let userFk;
if (!loopBackContext) userFk = 9;
else userFk = loopBackContext.active.accessToken.userId;
let action = setActionType(ctx); let action = setActionType(ctx);
let userFk = loopBackContext.active.accessToken.userId;
let logRecord = { let logRecord = {
originFk: originId, originFk: originId,