From 88847d3b4a2755e00b352d46fa64a4fd03527c1a Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 11 May 2016 19:56:58 +0200 Subject: [PATCH] Fix display of server-provided validation error when adding subscriber no issue - make the check for "email" in the server provided error case-insensitive --- core/client/app/components/modals/new-subscriber.js | 2 +- core/client/app/mirage/config.js | 4 ++-- core/client/tests/acceptance/subscribers-test.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/client/app/components/modals/new-subscriber.js b/core/client/app/components/modals/new-subscriber.js index 01e50958d7..246d24b7f7 100644 --- a/core/client/app/components/modals/new-subscriber.js +++ b/core/client/app/components/modals/new-subscriber.js @@ -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'); } diff --git a/core/client/app/mirage/config.js b/core/client/app/mirage/config.js index 3b88413420..742bd4491d 100644 --- a/core/client/app/mirage/config.js +++ b/core/client/app/mirage/config.js @@ -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' }] }); diff --git a/core/client/tests/acceptance/subscribers-test.js b/core/client/tests/acceptance/subscribers-test.js index b448f554d1..9c828b737c 100644 --- a/core/client/tests/acceptance/subscribers-test.js +++ b/core/client/tests/acceptance/subscribers-test.js @@ -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"')