diff options
author | Duda Dornelles <ddornell@thoughtworks.com> | 2014-12-18 14:36:10 -0200 |
---|---|---|
committer | Duda Dornelles <ddornell@thoughtworks.com> | 2014-12-18 14:37:14 -0200 |
commit | 8e57412dcd7fe8749ebed645e048309618ed01b5 (patch) | |
tree | d736ae52d3fbffee06e482b19702c78041c83f71 /web-ui | |
parent | 2d07349df9eb7fd3a197c0c3a9f7180af441f82c (diff) |
\#203 & #204 & #205: fixing client and api for buld mark as read/unread and delete, functional tests are still broken, investigating...
Diffstat (limited to 'web-ui')
-rw-r--r-- | web-ui/app/js/services/mail_service.js | 24 | ||||
-rw-r--r-- | web-ui/test/spec/services/mail_service.spec.js | 5 |
2 files changed, 15 insertions, 14 deletions
diff --git a/web-ui/app/js/services/mail_service.js b/web-ui/app/js/services/mail_service.js index 58b70ed7..24bceb31 100644 --- a/web-ui/app/js/services/mail_service.js +++ b/web-ui/app/js/services/mail_service.js @@ -80,13 +80,13 @@ define( mailIdents = _.map(data.checkedMails, function (mail) { return mail.ident; }); - monitoredAjax(this, '/mails/read', { - type: 'POST', - data: {idents: JSON.stringify(mailIdents)} - }).done(this.triggerMailsRead(data.checkedMails)); } else { - monitoredAjax(this, '/mail/' + data.ident + '/read', {type: 'POST'}); + mailIdents = [data.ident]; } + monitoredAjax(this, '/mails/read', { + type: 'POST', + data: JSON.stringify({idents: mailIdents}) + }).done(this.triggerMailsRead(data.checkedMails)); }; this.unreadMail = function (ev, data) { @@ -95,13 +95,13 @@ define( mailIdents = _.map(data.checkedMails, function (mail) { return mail.ident; }); - monitoredAjax(this, '/mails/unread', { - type: 'POST', - data: {idents: JSON.stringify(mailIdents)} - }).done(this.triggerMailsRead(data.checkedMails)); } else { - monitoredAjax(this, '/mail/' + data.ident + '/read', {type: 'POST'}); + mailIdents = [data.ident]; } + monitoredAjax(this, '/mails/unread', { + type: 'POST', + data: JSON.stringify({idents: mailIdents}) + }).done(this.triggerMailsRead(data.checkedMails)); }; this.triggerMailsRead = function (mails) { @@ -137,8 +137,8 @@ define( return mail.ident; }); - monitoredAjax(this, '/mails', { - type: 'DELETE', + monitoredAjax(this, '/mails/delete', { + type: 'POST', dataType: 'json', contentType: 'application/json; charset=utf-8', data: JSON.stringify({idents: mailIdents}) diff --git a/web-ui/test/spec/services/mail_service.spec.js b/web-ui/test/spec/services/mail_service.spec.js index be10b934..55ca81c0 100644 --- a/web-ui/test/spec/services/mail_service.spec.js +++ b/web-ui/test/spec/services/mail_service.spec.js @@ -18,7 +18,8 @@ describeComponent('services/mail_service', function () { this.component.trigger(Pixelated.events.mail.read, {ident: 1}); - expect(readRequest.calls.mostRecent().args[0]).toEqual('/mail/1/read'); + expect(readRequest.calls.mostRecent().args[0]).toEqual('/mails/read'); + expect(readRequest.calls.mostRecent().args[1].data).toEqual('{"idents":[1]}'); }); describe('when marks many emails as read', function () { @@ -42,7 +43,7 @@ describeComponent('services/mail_service', function () { it('makes the correct request to the backend', function () { expect(readRequest.calls.mostRecent().args[0]).toEqual('/mails/read'); - expect(readRequest.calls.mostRecent().args[1].data).toEqual({idents: '[1,2]'}); + expect(readRequest.calls.mostRecent().args[1].data).toEqual('{"idents":[1,2]}') }); it('will trigger that a message has been deleted when it is done deleting', function() { |