2014-07-30 18:56:01 -04:00
|
|
|
/* global asyncTest */
|
2014-09-26 14:48:34 -04:00
|
|
|
|
|
|
|
import siteFixtures from 'fixtures/site_fixtures';
|
|
|
|
|
|
|
|
export 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-09-26 14:48:34 -04:00
|
|
|
|
|
|
|
var siteJson = siteFixtures['site.json'].site;
|
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-09-26 14:48:34 -04:00
|
|
|
|
|
|
|
if (options.site) {
|
|
|
|
Discourse.Site.resetCurrent(Discourse.Site.create(jQuery.extend(true, {}, siteJson, options.site)));
|
|
|
|
}
|
2014-07-31 13:24:07 -04:00
|
|
|
}
|
2014-09-26 14:48:34 -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
|
|
|
}
|
|
|
|
|
2014-09-26 14:48:34 -04:00
|
|
|
export 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
|
|
|
}
|
|
|
|
|
2014-09-26 14:48:34 -04:00
|
|
|
export function asyncTestDiscourse(text, func) {
|
2013-07-15 19:47:13 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-09-26 14:48:34 -04:00
|
|
|
export function fixture(selector) {
|
2013-11-07 13:46:38 -05:00
|
|
|
if (selector) {
|
|
|
|
return $("#qunit-fixture").find(selector);
|
|
|
|
}
|
|
|
|
return $("#qunit-fixture");
|
|
|
|
}
|