summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorAlexandre Pretto Nunes <anunes@thoughtworks.com>2015-01-15 15:04:48 -0200
committerAlexandre Pretto Nunes <anunes@thoughtworks.com>2015-01-15 15:10:07 -0200
commit43a783e10f0b89820fb8d1e5677b0fdbcf7e9b6e (patch)
treecb0de1b1f540ab670f78f3cc02f2e28ac7a6071f /web-ui
parentee5ce9624a800bb85b05d3c73f4ca30c61443429 (diff)
#153 fix mail checking and unchecking on mail list
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/mail_list/ui/mail_items/mail_item.js1
-rw-r--r--web-ui/app/js/mail_list/ui/mail_list.js10
-rw-r--r--web-ui/app/js/services/mail_service.js6
-rw-r--r--web-ui/test/spec/mail_list/ui/mail_list.spec.js4
-rw-r--r--web-ui/test/spec/services/mail_service.spec.js29
-rw-r--r--web-ui/test/spec/tags/data/tags.spec.js6
6 files changed, 25 insertions, 31 deletions
diff --git a/web-ui/app/js/mail_list/ui/mail_items/mail_item.js b/web-ui/app/js/mail_list/ui/mail_items/mail_item.js
index 94f08a9f..f7ae2f0c 100644
--- a/web-ui/app/js/mail_list/ui/mail_items/mail_item.js
+++ b/web-ui/app/js/mail_list/ui/mail_items/mail_item.js
@@ -36,7 +36,6 @@ define(
this.doSelect = function () {
this.$node.addClass('selected');
- this.checkCheckbox();
};
this.doUnselect = function () {
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 c2746c88..69327a57 100644
--- a/web-ui/app/js/mail_list/ui/mail_list.js
+++ b/web-ui/app/js/mail_list/ui/mail_list.js
@@ -121,15 +121,15 @@ define(
};
this.updateCheckAllCheckbox = function () {
- this.trigger(document, events.ui.mails.hasMailsChecked, {hasMailsChecked: _.keys(this.attr.checkedMails).length > 0});
+ this.trigger(document, events.ui.mails.hasMailsChecked, _.keys(this.attr.checkedMails).length > 0);
};
- this.addToSelectedMails = function (ev, data) {
+ this.addToCheckedMails = function (ev, data) {
this.attr.checkedMails[data.mail.ident] = data.mail;
this.updateCheckAllCheckbox();
};
- this.removeFromSelectedMails = function (ev, data) {
+ this.removeFromCheckedMails = function (ev, data) {
if (data.mails) {
_.each(data.mails, function (mail) {
delete this.attr.checkedMails[mail.ident];
@@ -169,8 +169,8 @@ define(
this.on(document, events.ui.mail.updateSelected, this.updateSelected);
this.on(document, events.ui.mail.wantChecked, this.respondWithCheckedMails);
- this.on(document, events.ui.mail.checked, this.addToSelectedMails);
- this.on(document, events.ui.mail.unchecked, this.removeFromSelectedMails);
+ this.on(document, events.ui.mail.checked, this.addToCheckedMails);
+ this.on(document, events.ui.mail.unchecked, this.removeFromCheckedMails);
this.openMailFromUrl = utils.once(function () {
if (this.shouldSelectEmailFromUrlMailIdent()) {
diff --git a/web-ui/app/js/services/mail_service.js b/web-ui/app/js/services/mail_service.js
index ca8b1da1..1fa41619 100644
--- a/web-ui/app/js/services/mail_service.js
+++ b/web-ui/app/js/services/mail_service.js
@@ -108,8 +108,7 @@ define(
this.triggerMailsRead = function (mails) {
return _.bind(function () {
this.refreshMails();
- this.trigger(document, events.ui.mail.unchecked, { mails: mails });
- this.trigger(document, events.ui.mails.hasMailsChecked, false);
+ this.trigger(document, events.ui.mails.uncheckAll);
}, this);
};
@@ -119,8 +118,7 @@ define(
this.refreshMails();
this.trigger(document, events.ui.userAlerts.displayMessage, { message: dataToDelete.successMessage});
- this.trigger(document, events.ui.mail.unchecked, { mails: mails });
- this.trigger(document, events.ui.mails.hasMailsChecked, false);
+ this.trigger(document, events.ui.mails.uncheckAll);
this.trigger(document, events.mail.deleted, { mails: mails });
}, this);
};
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 72f61a39..22a10a31 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
@@ -108,7 +108,7 @@ describeComponent('mail_list/ui/mail_list', function () {
$(document).trigger(Pixelated.events.ui.mail.checked, {mail: mailList[0]});
- expect(setCheckAllCheckboxEvent).toHaveBeenTriggeredOnAndWith(document, {hasMailsChecked: true});
+ expect(setCheckAllCheckboxEvent).toHaveBeenTriggeredOnAndWith(document, true);
});
it('unchecks the check all checkbox if no mail is left checked', function () {
@@ -118,7 +118,7 @@ describeComponent('mail_list/ui/mail_list', function () {
$(document).trigger(Pixelated.events.ui.mail.unchecked, {mail: {ident: '1'}});
- expect(setCheckAllCheckboxEvent).toHaveBeenTriggeredOnAndWith(document, {hasMailsChecked: false});
+ expect(setCheckAllCheckboxEvent).toHaveBeenTriggeredOnAndWith(document, false);
});
});
diff --git a/web-ui/test/spec/services/mail_service.spec.js b/web-ui/test/spec/services/mail_service.spec.js
index 778d79da..685ad5bc 100644
--- a/web-ui/test/spec/services/mail_service.spec.js
+++ b/web-ui/test/spec/services/mail_service.spec.js
@@ -3,9 +3,13 @@
describeComponent('services/mail_service', function () {
var email1, i18n;
+ var features;
beforeEach( function () {
+ features = require('features');
+ spyOn(features, 'isAutoRefreshEnabled').and.returnValue(false);
this.setupComponent();
+
email1 = Pixelated.testData().parsedMail.simpleTextPlain;
i18n = require('views/i18n');
} );
@@ -21,7 +25,7 @@ describeComponent('services/mail_service', function () {
});
describe('when marks many emails as read', function () {
- var readRequest, checkedMails, uncheckedEmailsEvent, setCheckAllEvent, deferred;
+ var readRequest, checkedMails, uncheckAllEvent, deferred;
beforeEach(function () {
checkedMails = {
@@ -32,8 +36,7 @@ describeComponent('services/mail_service', function () {
deferred = $.Deferred();
readRequest = spyOn($, 'ajax').and.returnValue(deferred);
- uncheckedEmailsEvent = spyOnEvent(document, Pixelated.events.ui.mail.unchecked);
- setCheckAllEvent = spyOnEvent(document, Pixelated.events.ui.mails.hasMailsChecked);
+ uncheckAllEvent = spyOnEvent(document, Pixelated.events.ui.mails.uncheckAll);
spyOn(this.component, 'refreshMails');
this.component.trigger(Pixelated.events.mail.read, {checkedMails: checkedMails});
@@ -49,14 +52,9 @@ describeComponent('services/mail_service', function () {
expect(this.component.refreshMails).toHaveBeenCalled();
});
- it('unchecks read emails', function () {
- deferred.resolve(checkedMails);
- expect(uncheckedEmailsEvent).toHaveBeenTriggeredOnAndWith(document, {mails: checkedMails});
- });
-
it('clears the check all checkbox', function () {
deferred.resolve(checkedMails);
- expect(setCheckAllEvent).toHaveBeenTriggeredOnAndWith(document, false);
+ expect(uncheckAllEvent).toHaveBeenTriggeredOn(document);
});
});
@@ -133,12 +131,11 @@ describeComponent('services/mail_service', function () {
});
describe('when successfuly deletes an email', function () {
- var displayMessageEvent, uncheckedEmailsEvent, setCheckAllEvent, mailsDeletedEvent;
+ var displayMessageEvent, uncheckAllEvent, mailsDeletedEvent;
beforeEach(function () {
displayMessageEvent = spyOnEvent(document, Pixelated.events.ui.userAlerts.displayMessage);
- uncheckedEmailsEvent = spyOnEvent(document, Pixelated.events.ui.mail.unchecked);
- setCheckAllEvent = spyOnEvent(document, Pixelated.events.ui.mails.hasMailsChecked);
+ uncheckAllEvent = spyOnEvent(document, Pixelated.events.ui.mails.uncheckAll);
mailsDeletedEvent = spyOnEvent(document, Pixelated.events.mail.deleted);
spyOn(this.component, 'refreshMails');
@@ -156,16 +153,12 @@ describeComponent('services/mail_service', function () {
expect(displayMessageEvent).toHaveBeenTriggeredOnAndWith(document, {message: 'A success message'});
});
- it('unchecks deleted emails', function () {
- expect(uncheckedEmailsEvent).toHaveBeenTriggeredOnAndWith(document, { mails: {1: 'email 1', 2: 'email 2'} });
- });
-
it('tells about deleted emails', function () {
expect(mailsDeletedEvent).toHaveBeenTriggeredOnAndWith(document, { mails: {1: 'email 1', 2: 'email 2'} });
});
- it('clears the check all checkbox', function () {
- expect(setCheckAllEvent).toHaveBeenTriggeredOnAndWith(document, false);
+ it('unchecks all checked mails', function () {
+ expect(uncheckAllEvent).toHaveBeenTriggeredOn(document);
});
});
diff --git a/web-ui/test/spec/tags/data/tags.spec.js b/web-ui/test/spec/tags/data/tags.spec.js
index adb279ac..469ab0ce 100644
--- a/web-ui/test/spec/tags/data/tags.spec.js
+++ b/web-ui/test/spec/tags/data/tags.spec.js
@@ -3,7 +3,11 @@
describeComponent('tags/data/tags', function () {
'use strict';
- beforeEach(function () {
+ var features;
+
+ beforeEach( function () {
+ features = require('features');
+ spyOn(features, 'isAutoRefreshEnabled').and.returnValue(false);
this.setupComponent();
});