Commit 9a688950 by Clinton Blackburn

Fixed product validation bug

Skipping product validation when retrieving data from the server after saving.

ECOM-2075
parent f7c47204
......@@ -81,7 +81,9 @@ define([
}
},
products: function (value) {
if (!value.isValid()) {
// NOTE (CCB): When syncing from the server, the value is an array. We can safely ignore
// validation in this case since the values from the server should be valid.
if (!_.isArray(value) && !value.isValid()) {
return gettext('Product validation failed.');
}
}
......
......@@ -249,15 +249,23 @@ define([
});
describe('products validation', function () {
it('should return an error message if any product is invalid', function () {
var msg = 'Product validation failed.',
products = model.get('products');
describe('with single value', function () {
it('should return an error message if any product is invalid', function () {
var msg = 'Product validation failed.',
products = model.get('products');
// Add an invalid product
products.push(new ProfessionalSeat({price: null}));
// Add an invalid product
products.push(new ProfessionalSeat({price: null}));
expect(model.validate().products).toEqual(msg);
expect(model.isValid(true)).toBeFalsy();
expect(model.validate().products).toEqual(msg);
expect(model.isValid(true)).toBeFalsy();
});
});
describe('with non-products', function () {
it('should have an undefined return value', function () {
expect(model.validation.products([])).toBeUndefined();
});
});
});
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment