Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev There was a failure building this commit Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-09-23 13:55:28 +02:00
commit a48b3b31b7
3 changed files with 15 additions and 14 deletions

View File

@ -75,7 +75,6 @@ describe('Order edit basic data path', () => {
it('should navigate to the basic data section of the new order', async() => { it('should navigate to the basic data section of the new order', async() => {
const url = await nightmare const url = await nightmare
.wait(1999)
.accessToSection('order.card.basicData') .accessToSection('order.card.basicData')
.wait(selectors.orderBasicData.observationInput) .wait(selectors.orderBasicData.observationInput)
.parsedUrl(); .parsedUrl();

View File

@ -1,6 +1,6 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
describe('Client Create', () => { fdescribe('Client Create', () => {
const clientName = 'Wade'; const clientName = 'Wade';
const AccountName = 'Deadpool'; const AccountName = 'Deadpool';
@ -39,8 +39,6 @@ describe('Client Create', () => {
expect(account.name).toEqual(newAccount.userName); expect(account.name).toEqual(newAccount.userName);
client = await app.models.Client.findOne({where: {name: newAccount.name}});
expect(client.id).toEqual(account.id); expect(client.id).toEqual(account.id);
expect(client.name).toEqual(newAccount.name); expect(client.name).toEqual(newAccount.name);
expect(client.email).toEqual(newAccount.email); expect(client.email).toEqual(newAccount.email);

View File

@ -152,16 +152,6 @@ module.exports = Self => {
done(); done();
} }
Self.validateBinded('socialName', isAlpha, {
message: 'The socialName has an invalid format'
});
function isAlpha(value) {
const regexp = new RegExp(/^[a-zA-Z\s]*$/);
return regexp.test(value);
}
Self.validateAsync('postCode', hasValidPostcode, { Self.validateAsync('postCode', hasValidPostcode, {
message: `The postcode doesn't exists. Ensure you put the correct format` message: `The postcode doesn't exists. Ensure you put the correct format`
}); });
@ -177,12 +167,26 @@ module.exports = Self => {
done(); done();
} }
function isAlpha(value) {
const regexp = new RegExp(/^[ñça-zA-Z\s]*$/);
return regexp.test(value);
}
Self.observe('before save', async function(ctx) { Self.observe('before save', async function(ctx) {
let changes = ctx.data || ctx.instance; let changes = ctx.data || ctx.instance;
let orgData = ctx.currentInstance; let orgData = ctx.currentInstance;
let finalState = getFinalState(ctx); let finalState = getFinalState(ctx);
let payMethodWithIban = 4; let payMethodWithIban = 4;
// Validate socialName format
const socialNameChanged = orgData && changes
&& orgData.socialName != changes.socialName;
if (socialNameChanged && !isAlpha(changes.socialName))
throw new UserError('The socialName has an invalid format');
if (changes.salesPerson === null) { if (changes.salesPerson === null) {
changes.credit = 0; changes.credit = 0;
changes.discount = 0; changes.discount = 0;