From 32fe00c7b23883a0ce35910537cb1966457624cb Mon Sep 17 00:00:00 2001 From: Alexandre Pretto Nunes Date: Fri, 19 Dec 2014 17:53:52 -0200 Subject: #81 Fix checking if any mail is marked when on 'all' tag --- web-ui/app/js/mail_list/ui/mail_list.js | 2 +- web-ui/test/spec/mail_list/ui/mail_list.spec.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/web-ui/app/js/mail_list/ui/mail_list.js b/web-ui/app/js/mail_list/ui/mail_list.js index da79f20b..56c5c4f9 100644 --- a/web-ui/app/js/mail_list/ui/mail_list.js +++ b/web-ui/app/js/mail_list/ui/mail_list.js @@ -134,7 +134,7 @@ define( this.checkedMailsForCurrentTag = function () { var checkedMailsForCurrentTag = _.filter(self.attr.checkedMails, function (mail) { - return mail.mailbox === self.attr.currentTag || _.contains(mail.tags, self.attr.currentTag); + return self.attr.currentTag === 'all' || mail.mailbox === self.attr.currentTag || _.contains(mail.tags, self.attr.currentTag); }); return checkedMailsForCurrentTag.length > 0 ? checkedMailsForCurrentTag : {}; diff --git a/web-ui/test/spec/mail_list/ui/mail_list.spec.js b/web-ui/test/spec/mail_list/ui/mail_list.spec.js index 5c285110..003830de 100644 --- a/web-ui/test/spec/mail_list/ui/mail_list.spec.js +++ b/web-ui/test/spec/mail_list/ui/mail_list.spec.js @@ -75,7 +75,18 @@ describeComponent('mail_list/ui/mail_list', function () { it('returns the list of checked mails based on the current tag to whomever requests them', function () { var caller = {}; this.component.attr.checkedMails = mailList; - this.component.attr.currentTag = 'inbox'; + this.component.attr.currentTag = 'inbox'; + var mailHereCheckedEvent = spyOnEvent(caller, Pixelated.events.ui.mail.hereChecked); + + $(document).trigger(Pixelated.events.ui.mail.wantChecked, caller); + + expect(mailHereCheckedEvent).toHaveBeenTriggeredOnAndWith(caller, { checkedMails: mailList }); + }); + + it('returns every checked mail when the curent tag is "all"', function () { + var caller = {}; + this.component.attr.checkedMails = mailList; + this.component.attr.currentTag = 'all'; var mailHereCheckedEvent = spyOnEvent(caller, Pixelated.events.ui.mail.hereChecked); $(document).trigger(Pixelated.events.ui.mail.wantChecked, caller); -- cgit v1.2.3