Fix display of server-provided validation error when adding subscriber

no issue
- make the check for "email" in the server provided error case-insensitive
This commit is contained in:
Kevin Ansfield 2016-05-11 19:56:58 +02:00
parent e6fe1c672c
commit 88847d3b4a
3 changed files with 4 additions and 4 deletions

View File

@ -18,7 +18,7 @@ export default ModalComponent.extend({
this.send('closeModal');
}).catch((errors) => {
let [error] = errors;
if (error && error.match(/email/)) {
if (error && error.match(/email/i)) {
this.get('model.errors').add('email', error);
this.get('model.hasValidated').pushObject('email');
}

View File

@ -60,8 +60,8 @@ function mockSubscribers(server) {
if (subscriber) {
return new Mirage.Response(422, {}, {
errors: [{
errorType: 'DataImportError',
message: 'duplicate email',
errorType: 'ValidationError',
message: 'Email already exists.',
property: 'email'
}]
});

View File

@ -177,7 +177,7 @@ describe('Acceptance: Subscribers', function() {
andThen(function () {
// the validation error is displayed
expect(find('.fullscreen-modal .error .response').text().trim(), 'duplicate email validation')
.to.match(/duplicate/);
.to.equal('Email already exists.');
// the subscriber is not added to the table
expect(find('.lt-cell:contains(test@example.com)').length, 'number of "test@example.com rows"')