Merge pull request #6811 from kevinansfield/fix-new-subscriber-validation

Fix display of server-provided validation error when adding subscriber
This commit is contained in:
Hannah Wolfe 2016-05-11 22:24:28 +02:00
commit 585f582991
3 changed files with 4 additions and 4 deletions

View File

@ -18,7 +18,7 @@ export default ModalComponent.extend({
this.send('closeModal'); this.send('closeModal');
}).catch((errors) => { }).catch((errors) => {
let [error] = 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.errors').add('email', error);
this.get('model.hasValidated').pushObject('email'); this.get('model.hasValidated').pushObject('email');
} }

View File

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

View File

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