aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2017-04-25 22:01:56 +0200
committerGeorg Ehrke <developer@georgehrke.com>2017-04-26 09:30:21 +0200
commit6bbc682c4b24212d36ef595d3692653dca1c67b1 (patch)
tree3fe0b80d575f8c04cef218de59b2167c34a7ae5a /core
parent99b201a188a346c6af832e0d083cc4a958bbb32e (diff)
downloadnextcloud-server-6bbc682c4b24212d36ef595d3692653dca1c67b1.tar.gz
nextcloud-server-6bbc682c4b24212d36ef595d3692653dca1c67b1.zip
handle 404 separately
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'core')
-rw-r--r--core/js/jquery.contactsmenu.js11
-rw-r--r--core/js/tests/specs/jquery.contactsmenuSpec.js15
2 files changed, 24 insertions, 2 deletions
diff --git a/core/js/jquery.contactsmenu.js b/core/js/jquery.contactsmenu.js
index 84f5a3f9eab..1ea9f732f79 100644
--- a/core/js/jquery.contactsmenu.js
+++ b/core/js/jquery.contactsmenu.js
@@ -78,13 +78,20 @@
if (actions.length === 0) {
}
- }, function() {
+ }, function(jqXHR) {
$list.find('ul').find('li').addClass('hidden');
+ var title;
+ if (jqXHR.status === 404) {
+ title = t('core', 'No action available');
+ } else {
+ title = t('core', 'Error fetching contact actions');
+ }
+
var template = Handlebars.compile(ENTRY);
$list.find('ul').append(template({
hyperlink: '#',
- title: t('core', 'Error fetching contact actions')
+ title: title
}));
});
});
diff --git a/core/js/tests/specs/jquery.contactsmenuSpec.js b/core/js/tests/specs/jquery.contactsmenuSpec.js
index b979be8883f..7287648f5a2 100644
--- a/core/js/tests/specs/jquery.contactsmenuSpec.js
+++ b/core/js/tests/specs/jquery.contactsmenuSpec.js
@@ -184,6 +184,21 @@ describe('jquery.contactsMenu tests', function() {
expect($appendTo.html()).toEqual('<div class="menu popovermenu bubble contactsmenu-popover loaded" style="display: block;"> <ul> <li class="hidden"> <a> <span class="icon-loading-small"></span> </a> </li> <li> <a href="#"> <span>Error fetching contact actions</span> </a></li></ul></div>');
});
+
+ it('should handle 404', function() {
+ $('#selector1, #selector2').contactsMenu('user', 0, $appendTo);
+ $selector1.click();
+
+ fakeServer.requests[0].respond(
+ 404,
+ { 'Content-Type': 'application/json; charset=utf-8' },
+ JSON.stringify([])
+ );
+ expect(fakeServer.requests[0].method).toEqual('POST');
+ expect(fakeServer.requests[0].url).toEqual('http://localhost/index.php/contactsmenu/findOne');
+
+ expect($appendTo.html()).toEqual('<div class="menu popovermenu bubble contactsmenu-popover loaded" style="display: block;"> <ul> <li class="hidden"> <a> <span class="icon-loading-small"></span> </a> </li> <li> <a href="#"> <span>No action available</span> </a></li></ul></div>');
+ });
});
it('click anywhere else to close the menu', function() {