[Libreoffice-commits] .: 2 commits - bug/bug
Loic Dachary
loic at kemper.freedesktop.org
Sat Sep 17 05:32:19 PDT 2011
bug/bug/bug.js | 19 +++++++++++++++++--
bug/bug/test.js | 31 +++++++++++++++++++++++++++++--
2 files changed, 46 insertions(+), 4 deletions(-)
New commits:
commit 9bea99d4e2cddb96f567bf72ee699e9d6e8395fe
Author: Loic Dachary <loic at dachary.org>
Date: Sat Sep 17 14:32:02 2011 +0200
If an ajax call fails, abort and display and error message in the page itself so that it is not transparently ignored.
diff --git a/bug/bug/bug.js b/bug/bug/bug.js
index 7eadd4a..daaae32 100644
--- a/bug/bug/bug.js
+++ b/bug/bug/bug.js
@@ -18,7 +18,22 @@
$.bug = {
- post: $.post,
+ post: function(url, args, callback) {
+ return $.post(url, args, callback).pipe(null, function(error) {
+ var message = url + ' XHR error. ';
+ if('status' in error) {
+ message += 'status = ' + error.status + ' ';
+ }
+ if('responseText' in error) {
+ message += 'responseText = ' + error.responseText + ' ';
+ }
+ if('statusText' in error) {
+ message += 'statusText = ' + error.statusText + ' ';
+ }
+ $('.error').text(message);
+ throw error;
+ });
+ },
get: $.get,
diff --git a/bug/bug/test.js b/bug/bug/test.js
index 6cc946a..ca517ed 100644
--- a/bug/bug/test.js
+++ b/bug/bug/test.js
@@ -16,6 +16,33 @@
//
module("bug");
+test("post", function() {
+ expect(4);
+
+ var status = 404;
+ var statusText = 'Status text';
+ var responseText = 'Error text';
+ var post = $.post;
+ $.post = function(url, args) {
+ return $.Deferred().reject({
+ status: status,
+ statusText: statusText,
+ responseText: responseText
+ });
+ };
+
+ try {
+ $.bug.post('DOESNOTEXIST', null);
+ } catch(e) {
+ ok($('.error').text().indexOf(status) >= 0, status);
+ ok($('.error').text().indexOf(statusText) >= 0, statusText);
+ ok($('.error').text().indexOf(responseText) >= 0, responseText);
+ equal(e.status, status);
+ }
+
+ $.post = post;
+});
+
test("lookup_result", function() {
expect(7);
@@ -39,8 +66,8 @@ test("lookup_result", function() {
var bugous = 'BUGOUS OUTPUT';
try {
$.bug.lookup_result(bugous, error_regexp, success_regexp);
- } catch(e) {
- equal(e, bugous);
+ } catch(ee) {
+ equal(ee, bugous);
ok($('.error').text().indexOf(success_regexp) >= 0, 'error displayed');
caught = true;
}
commit 2f3d25b54e2f4c97b98c768336bdf51a6b09c979
Author: Loic Dachary <loic at dachary.org>
Date: Sat Sep 17 13:34:34 2011 +0200
use html instead of text to display the user name so that @ is not converted in @
diff --git a/bug/bug/bug.js b/bug/bug/bug.js
index 5525e37..7eadd4a 100644
--- a/bug/bug/bug.js
+++ b/bug/bug/bug.js
@@ -53,7 +53,7 @@
$.bug.state_signin_error_regexp,
$.bug.state_signin_success_regexp);
}).pipe(function(data) {
- $('.username').text(data);
+ $('.username').html(data);
element.hide();
$.bug.state_component();
});
More information about the Libreoffice-commits
mailing list