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