2014-07-30 18:56:01 -04:00
|
|
|
/* global asyncTest */
|
2014-03-11 02:30:49 -04:00
|
|
|
/* exported integration, testController, controllerFor, asyncTestDiscourse, fixture */
|
2014-07-31 17:59:52 -04:00
|
|
|
function integration(name, options) {
|
2013-07-04 16:19:59 -04:00
|
|
|
module("Integration: " + name, {
|
2013-06-20 13:58:54 -04:00
|
|
|
setup: function() {
|
|
|
|
Ember.run(Discourse, Discourse.advanceReadiness);
|
2014-07-31 17:59:52 -04:00
|
|
|
if (options) {
|
|
|
|
if (options.setup) {
|
|
|
|
options.setup.call(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.user) {
|
|
|
|
Discourse.User.resetCurrent(Discourse.User.create(options.user));
|
|
|
|
}
|
2014-07-31 13:24:07 -04:00
|
|
|
|
2014-07-31 17:59:52 -04:00
|
|
|
if (options.settings) {
|
|
|
|
Discourse.SiteSettings = jQuery.extend(true, Discourse.SiteSettings, options.settings);
|
|
|
|
}
|
2014-07-31 13:24:07 -04:00
|
|
|
}
|
2014-07-30 18:56:01 -04:00
|
|
|
Discourse.reset();
|
2013-06-20 13:58:54 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
teardown: function() {
|
2014-07-31 17:59:52 -04:00
|
|
|
if (options && options.teardown) {
|
|
|
|
options.teardown.call(this);
|
2013-11-05 11:42:37 -05:00
|
|
|
}
|
|
|
|
|
2013-06-20 13:58:54 -04:00
|
|
|
Discourse.reset();
|
|
|
|
}
|
|
|
|
});
|
2013-06-20 17:20:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function controllerFor(controller, model) {
|
2014-03-11 02:30:49 -04:00
|
|
|
controller = Discourse.__container__.lookup('controller:' + controller);
|
2013-06-20 17:20:08 -04:00
|
|
|
if (model) { controller.set('model', model ); }
|
|
|
|
return controller;
|
2013-07-15 19:47:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function asyncTestDiscourse(text, func) {
|
|
|
|
asyncTest(text, function () {
|
2013-10-07 11:36:20 -04:00
|
|
|
var self = this;
|
2013-07-15 19:47:13 -04:00
|
|
|
Ember.run(function () {
|
2013-10-07 11:36:20 -04:00
|
|
|
func.call(self);
|
2013-07-15 19:47:13 -04:00
|
|
|
});
|
|
|
|
});
|
2013-11-07 13:46:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function fixture(selector) {
|
|
|
|
if (selector) {
|
|
|
|
return $("#qunit-fixture").find(selector);
|
|
|
|
}
|
|
|
|
return $("#qunit-fixture");
|
|
|
|
}
|