Tarea #600 changed client.update for update attributes to make it compatible with logs
This commit is contained in:
parent
bb46980f3f
commit
b74da9da84
|
@ -1,14 +1,16 @@
|
|||
const app = require(`${servicesDir}/client/server/server`);
|
||||
|
||||
describe('Client addressesPropagateRe', () => {
|
||||
let client;
|
||||
beforeEach(async() => {
|
||||
client = await app.models.Client.findById(101);
|
||||
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() => {
|
||||
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() => {
|
||||
|
|
|
@ -32,10 +32,6 @@ describe('Client updateBasicData', () => {
|
|||
|
||||
let result = await app.models.Client.updateBasicData(validparams, id);
|
||||
|
||||
expect(result).toEqual({count: 1});
|
||||
|
||||
let updatedClient = await app.models.Client.findById(101);
|
||||
|
||||
expect(updatedClient.email).toEqual('myNewEmail@myDomain.es');
|
||||
expect(result.email).toEqual('myNewEmail@myDomain.es');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -50,10 +50,6 @@ describe('Client updateFiscalData', () => {
|
|||
|
||||
let result = await app.models.Client.updateFiscalData(ctxOfAdmin, validparams, idWithDataChecked);
|
||||
|
||||
expect(result).toEqual({count: 1});
|
||||
|
||||
let updatedClient = await app.models.Client.findById(idWithDataChecked);
|
||||
|
||||
expect(updatedClient.postcode).toEqual('12345');
|
||||
expect(result.postcode).toEqual('12345');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@ module.exports = Self => {
|
|||
if (validUpdateParams.indexOf(key) === -1)
|
||||
throw new UserError(`You don't have enough privileges to do that`);
|
||||
}
|
||||
|
||||
return await Self.app.models.Client.update({id: id}, params);
|
||||
let client = await Self.app.models.Client.findById(id);
|
||||
return await client.updateAttributes(params);
|
||||
};
|
||||
};
|
||||
|
|
|
@ -61,6 +61,8 @@ module.exports = Self => {
|
|||
}
|
||||
|
||||
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);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue