diff options
author | John Christopher Anderson <jchris@apache.org> | 2010-01-05 18:11:58 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2010-01-05 18:11:58 +0000 |
commit | 3a1f041e07c75001cf52cbae1391dcd801c17396 (patch) | |
tree | 749cf6441f847bea450f007b46b01a506beb4a58 /share/www/script/couch_test_runner.js | |
parent | 47d4f324ec2fe0e4ab907b8a023bc689c8192fb1 (diff) |
merge account branch to apache branch
git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/account@896158 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script/couch_test_runner.js')
-rw-r--r-- | share/www/script/couch_test_runner.js | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/share/www/script/couch_test_runner.js b/share/www/script/couch_test_runner.js index a5ece9cd..ed67d744 100644 --- a/share/www/script/couch_test_runner.js +++ b/share/www/script/couch_test_runner.js @@ -63,6 +63,8 @@ var numFailures = 0; var currentRow = null; function runTest(button, callback, debug, noSave) { + + // offer to save admins if (currentRow != null) { alert("Can not run multiple tests simultaneously."); return; @@ -116,6 +118,62 @@ function showSource(cell) { win.document.location = "script/test/" + name + ".js"; } +var readyToRun; +function setupAdminParty(fun) { + if (readyToRun) { + fun(); + } else { + function removeAdmins(confs, doneFun) { + // iterate through the config and remove current user last + // current user is at front of list + var remove = confs.pop(); + if (remove) { + $.couch.config({ + success : function() { + removeAdmins(confs, doneFun); + } + }, "admins", remove[0], null); + } else { + doneFun(); + } + }; + $.couch.session({ + success : function(userCtx) { + if (userCtx.name && userCtx.roles.indexOf("_admin") != -1) { + // admin but not admin party. dialog offering to make admin party + $.showDialog("dialog/_admin_party.html", { + submit: function(data, callback) { + $.couch.config({ + success : function(conf) { + var meAdmin, adminConfs = []; + for (var name in conf) { + if (name == userCtx.name) { + meAdmin = [name, conf[name]]; + } else { + adminConfs.push([name, conf[name]]); + } + } + adminConfs.unshift(meAdmin); + removeAdmins(adminConfs, function() { + callback(); + $.futon.session.sidebar(); + readyToRun = true; + setTimeout(fun, 500); + }); + } + }, "admins"); + } + }); + } else { + // not a logged in admin. + readyToRun = true; + fun(); + }; + } + }); + } +}; + function updateTestsListing() { for (var name in couchTests) { var testFunction = couchTests[name]; @@ -128,7 +186,11 @@ function updateTestsListing() { .find("td:nth(2)").addClass("details").end(); $("<button type='button' class='run' title='Run test'></button>").click(function() { this.blur(); - runTest(this); + var self = this; + // check for admin party + setupAdminParty(function() { + runTest(self); + }); return false; }).prependTo(row.find("th")); row.attr("id", name).appendTo("#tests tbody.content"); |