summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/resources/mail_resource.py2
-rw-r--r--service/test/integration/test_tags.py10
-rw-r--r--service/test/support/integration/app_test_client.py2
-rw-r--r--service/test/support/integration/soledad_test_base.py10
-rw-r--r--web-ui/app/js/mail_view/ui/mail_view.js4
-rw-r--r--web-ui/test/spec/mail_view/ui/mail_view.spec.js20
6 files changed, 36 insertions, 12 deletions
diff --git a/service/pixelated/resources/mail_resource.py b/service/pixelated/resources/mail_resource.py
index 03873ffb..396ccd74 100644
--- a/service/pixelated/resources/mail_resource.py
+++ b/service/pixelated/resources/mail_resource.py
@@ -15,7 +15,7 @@ class MailTags(Resource):
def render_POST(self, request):
content_dict = json.loads(request.content.read())
- new_tags = map(lambda tag: tag.lower(), content_dict['newtags'])
+ new_tags = [x.lower() for x in content_dict['newtags'] if x != '']
try:
self._mail_service.update_tags(self._mail_id, new_tags)
mail = self._mail_service.mail(self._mail_id)
diff --git a/service/test/integration/test_tags.py b/service/test/integration/test_tags.py
index 6072392c..b32e89c7 100644
--- a/service/test/integration/test_tags.py
+++ b/service/test/integration/test_tags.py
@@ -42,6 +42,16 @@ class TagsTest(SoledadTestBase):
mails = self.get_mails_by_tag('important')
self.assertEquals('Mail with tags', mails[0].subject)
+ def test_empty_tags_are_not_allowed(self):
+ mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
+ self.client.add_mail_to_inbox(mail)
+
+ self.post_tags(mail.ident, self._tags_json(['tag1', '']))
+
+ mail = self.get_mail(mail.ident)
+
+ self.assertEquals(mail['tags'], ['tag1'])
+
def test_addition_of_reserved_tags_is_not_allowed(self):
mail = MailBuilder().with_subject('Mail with tags').build_input_mail()
self.client.add_mail_to_inbox(mail)
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py
index 860b9c40..e8f79d2b 100644
--- a/service/test/support/integration/app_test_client.py
+++ b/service/test/support/integration/app_test_client.py
@@ -106,7 +106,7 @@ class AppTestClient:
time.sleep(1)
return lambda: process.terminate()
- def get(self, path, get_args, as_json=True):
+ def get(self, path, get_args='', as_json=True):
request = request_mock(path)
request.args = get_args
return self._render(request, as_json)
diff --git a/service/test/support/integration/soledad_test_base.py b/service/test/support/integration/soledad_test_base.py
index 5892de60..f7693ad4 100644
--- a/service/test/support/integration/soledad_test_base.py
+++ b/service/test/support/integration/soledad_test_base.py
@@ -25,12 +25,6 @@ class SoledadTestBase(unittest.TestCase):
DEFERRED_TIMEOUT = 120
DEFERRED_TIMEOUT_LONG = 300
- @classmethod
- def setUpClass(cls):
- from nose.twistedtools import threaded_reactor
-
- threaded_reactor()
-
def setUp(self):
self.client = AppTestClient()
@@ -66,6 +60,10 @@ class SoledadTestBase(unittest.TestCase):
res, req = self.client.get('/tags', kwargs)
return res
+ def get_mail(self, mail_ident):
+ res, req = self.client.get('/mail/%s' % mail_ident)
+ return res
+
def delete_mail(self, mail_ident):
res, req = self.client.delete("/mail/%s" % mail_ident)
return req
diff --git a/web-ui/app/js/mail_view/ui/mail_view.js b/web-ui/app/js/mail_view/ui/mail_view.js
index 66b33748..eb55dbd5 100644
--- a/web-ui/app/js/mail_view/ui/mail_view.js
+++ b/web-ui/app/js/mail_view/ui/mail_view.js
@@ -157,7 +157,9 @@ define(
if (event.which === ENTER_KEY){
event.preventDefault();
- this.createNewTag();
+ if (this.select('newTagInput').val() !== '') {
+ this.createNewTag();
+ }
} else if (event.which === ESC_KEY) {
event.preventDefault();
this.addTagLoseFocus();
diff --git a/web-ui/test/spec/mail_view/ui/mail_view.spec.js b/web-ui/test/spec/mail_view/ui/mail_view.spec.js
index de6fc29d..7d464bcd 100644
--- a/web-ui/test/spec/mail_view/ui/mail_view.spec.js
+++ b/web-ui/test/spec/mail_view/ui/mail_view.spec.js
@@ -166,22 +166,36 @@ describeComponent('mail_view/ui/mail_view', function () {
it('creates new tag when pressing Enter key on new tag input', function(){
var tagsUpdateEvent = spyOnEvent(document, Pixelated.events.mail.tags.update);
- var tagListRefreshEvent = spyOnEvent(document, Pixelated.events.dispatchers.tags.refreshTagList);
- var e = creatingEvent('keydown', 13);
this.component.displayMail({}, testData);
this.component.select('newTagButton').click();
var newTagInputComponent = this.component.select('newTagInput');
newTagInputComponent.val('Test');
+
+ var e = creatingEvent('keydown', 13); //ENTER KEY EVENT
newTagInputComponent.trigger(e);
var tags = testData.mail.tags.slice();
tags.push('Test');
-
expect(tagsUpdateEvent).toHaveBeenTriggeredOnAndWith(document, { ident: testData.mail.ident, tags: tags});
});
+ it('creates new tag when pressing Enter key on new tag input', function(){
+ var tagsUpdateEvent = spyOnEvent(document, Pixelated.events.mail.tags.update);
+
+ this.component.displayMail({}, testData);
+ this.component.select('newTagButton').click();
+
+ var newTagInputComponent = this.component.select('newTagInput');
+ newTagInputComponent.val('');
+
+ var e = creatingEvent('keydown', 13); //ENTER KEY EVENT
+ newTagInputComponent.trigger(e);
+
+ expect(tagsUpdateEvent).not.toHaveBeenTriggeredOnAndWith(document);
+ });
+
it('trigger mail delete event when moving email to trash', function(){
var mailDeleteEvent = spyOnEvent(document, Pixelated.events.ui.mail.delete);