ES6: Notification controllers, added helper to create via ES6/container

This commit is contained in:
Robin Ward 2014-05-12 14:01:21 -04:00
parent 51750f7d0e
commit 07007e6cbc
6 changed files with 19 additions and 15 deletions

View File

@ -1,4 +1,4 @@
Discourse.NotificationController = Discourse.ObjectController.extend({
export default Discourse.ObjectController.extend({
scope: function() {
return "notifications." + Discourse.Site.currentProp("notificationLookup")[this.get("notification_type")];
}.property(),

View File

@ -0,0 +1,4 @@
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
needs: ['header'],
itemController: "notification"
});

View File

@ -1,4 +0,0 @@
Discourse.NotificationsController = Ember.ArrayController.extend(Discourse.HasCurrentUser, {
needs: ['header'],
itemController: "notification"
});

View File

@ -11,13 +11,10 @@ var notificationFixture = {
};
var postUrlStub = "post-url-stub";
module("Discourse.NotificationController", {
module("controller:notification", {
setup: function() {
sinon.stub(Discourse.Utilities, "postUrl").returns(postUrlStub);
controller = Discourse.NotificationController.create({
content: notificationFixture
});
controller = testController('notification', notificationFixture);
},
teardown: function() {

View File

@ -10,16 +10,14 @@ var noItemsMessageSelector = "div.none";
var itemListSelector = "ul";
var itemSelector = "li";
module("Discourse.NotificationsController", {
module("controller:notifications", {
setup: function() {
sinon.stub(I18n, "t", function (scope, options) {
options = options || {};
return [scope, options.username, options.link].join(" ").trim();
});
controller = Discourse.NotificationsController.create({
container: Discourse.__container__
});
controller = testController('notifications');
view = Ember.View.create({
container: Discourse.__container__,

View File

@ -1,4 +1,4 @@
/* global asyncTest */
/* global asyncTest, requirejs, require */
/* exported integration, testController, controllerFor, asyncTestDiscourse, fixture */
function integration(name, lifecycle) {
module("Integration: " + name, {
@ -25,6 +25,15 @@ function integration(name, lifecycle) {
}
function testController(klass, model) {
// HAX until we get ES6 everywhere:
if (typeof klass === "string") {
var moduleName = 'discourse/controllers/' + klass,
module = requirejs.entries[moduleName];
if (module) {
klass = require(moduleName, null, null, true).default;
}
}
return klass.create({model: model, container: Discourse.__container__});
}