diff options
| author | Christophe Simonis <chs@openerp.com> | 2014-02-20 17:17:53 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2014-02-20 17:17:53 +0100 |
| commit | 49f26ffbc81288ea0d17379121efc4280034246c (patch) | |
| tree | fb2e409f4035088875a095e7c618a0894314f456 /addons/web/static/src/js/testing.js | |
| parent | cbc987191cf2480c7b5e5623ec9de04c78de0bf8 (diff) | |
| parent | 2a4d8bc6d5e1e0efa382beb3381460f49d201dec (diff) | |
[MERGE] forward port of branch saas-2 up to revid 3950 dle@openerp.com-20140220141302-3paib80ixiyi66qg
bzr revid: chs@openerp.com-20140220161753-ec6l9ser1pbnmzgk
Diffstat (limited to 'addons/web/static/src/js/testing.js')
| -rw-r--r-- | addons/web/static/src/js/testing.js | 38 |
1 files changed, 32 insertions, 6 deletions
diff --git a/addons/web/static/src/js/testing.js b/addons/web/static/src/js/testing.js index f607b278437..c4f5aeebd60 100644 --- a/addons/web/static/src/js/testing.js +++ b/addons/web/static/src/js/testing.js @@ -15,6 +15,37 @@ openerp.testing = {}; list_editable: ['list', 'form', 'data'], }; + var initialized = []; + /** + * openerp.init is a broken-ass piece of shit, makes it impossible to + * progressively add modules, using it, retarded openerp_inited flag + * means the first tests being run get their dependencies loaded + * (basically just base and web), and for *every other module* the tests + * run without the dependencies being correctly loaded + */ + function init(modules) { + if (!initialized.length) { + openerp.init(modules); + initialized = openerp._modules.slice(); + return; + } + var to_initialize = _.difference(modules, initialized); + for (var i = 0; i < to_initialize.length; i++) { + var modname = to_initialize[i]; + var fct = openerp[modname]; + if (typeof fct === 'function') { + var module = openerp[modname] = {}; + for(var k in fct) { + if (!fct.hasOwnProperty(k)) { continue; } + module[k] = fct[k]; + } + fct(openerp, module) + } + initialized.push(modname); + openerp._modules.push(modname); + } + } + testing.dependencies = window['oe_all_dependencies'] || []; testing.current_module = null; testing.templates = { }; @@ -165,8 +196,6 @@ openerp.testing = {}; }); }; - var openerp_inited = false; - var db = window['oe_db_info']; testing.section = function (name, options, body) { if (_.isFunction(options)) { @@ -243,10 +272,7 @@ openerp.testing = {}; QUnit.test(name, function () { var instance = openerp; - if (!openerp_inited) { - openerp.init(module_deps); - openerp_inited = true; - } + init(module_deps); instance.session = new instance.web.Session(); instance.session.uid = 42; if (_.isNumber(opts.asserts)) { |
