2015-08-27 03:51:56 +08:00
|
|
|
import AppEvents from 'discourse/lib/app-events';
|
2015-07-15 01:56:59 +08:00
|
|
|
import createStore from 'helpers/create-store';
|
2016-03-19 04:31:59 +08:00
|
|
|
import { autoLoadModules } from 'discourse/initializers/auto-load-modules';
|
2015-07-15 01:56:59 +08:00
|
|
|
|
|
|
|
export default function(name, opts) {
|
|
|
|
opts = opts || {};
|
|
|
|
|
|
|
|
test(name, function(assert) {
|
2015-08-27 03:51:56 +08:00
|
|
|
const appEvents = AppEvents.create();
|
2016-03-22 02:16:05 +08:00
|
|
|
this.site = Discourse.Site.current();
|
|
|
|
|
2015-07-15 01:56:59 +08:00
|
|
|
this.container.register('site-settings:main', Discourse.SiteSettings, { instantiate: false });
|
2015-08-27 03:51:56 +08:00
|
|
|
this.container.register('app-events:main', appEvents, { instantiate: false });
|
2015-09-03 04:17:46 +08:00
|
|
|
this.container.register('capabilities:main', Ember.Object);
|
2016-03-22 02:16:05 +08:00
|
|
|
this.container.register('site:main', this.site, { instantiate: false });
|
2015-07-15 01:56:59 +08:00
|
|
|
this.container.injection('component', 'siteSettings', 'site-settings:main');
|
2015-08-27 03:51:56 +08:00
|
|
|
this.container.injection('component', 'appEvents', 'app-events:main');
|
2015-09-03 04:17:46 +08:00
|
|
|
this.container.injection('component', 'capabilities', 'capabilities:main');
|
2016-02-19 01:18:43 +08:00
|
|
|
this.container.injection('component', 'site', 'site:main');
|
2015-07-15 01:56:59 +08:00
|
|
|
|
2016-01-05 04:18:09 +08:00
|
|
|
this.siteSettings = Discourse.SiteSettings;
|
|
|
|
|
2016-03-19 04:31:59 +08:00
|
|
|
autoLoadModules();
|
2016-01-05 04:18:09 +08:00
|
|
|
|
|
|
|
if (opts.setup) {
|
|
|
|
const store = createStore();
|
|
|
|
this.currentUser = Discourse.User.create();
|
|
|
|
this.container.register('store:main', store, { instantiate: false });
|
|
|
|
this.container.register('current-user:main', this.currentUser, { instantiate: false });
|
|
|
|
opts.setup.call(this, store);
|
|
|
|
}
|
|
|
|
|
2015-09-29 02:01:16 +08:00
|
|
|
andThen(() => this.render(opts.template));
|
|
|
|
andThen(() => opts.test.call(this, assert));
|
2015-07-15 01:56:59 +08:00
|
|
|
});
|
|
|
|
}
|