mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 11:19:51 +00:00
ES6: Notification controllers, added helper to create via ES6/container
This commit is contained in:
parent
51750f7d0e
commit
07007e6cbc
@ -1,4 +1,4 @@
|
|||||||
Discourse.NotificationController = Discourse.ObjectController.extend({
|
export default Discourse.ObjectController.extend({
|
||||||
scope: function() {
|
scope: function() {
|
||||||
return "notifications." + Discourse.Site.currentProp("notificationLookup")[this.get("notification_type")];
|
return "notifications." + Discourse.Site.currentProp("notificationLookup")[this.get("notification_type")];
|
||||||
}.property(),
|
}.property(),
|
@ -0,0 +1,4 @@
|
|||||||
|
export default Ember.ArrayController.extend(Discourse.HasCurrentUser, {
|
||||||
|
needs: ['header'],
|
||||||
|
itemController: "notification"
|
||||||
|
});
|
@ -1,4 +0,0 @@
|
|||||||
Discourse.NotificationsController = Ember.ArrayController.extend(Discourse.HasCurrentUser, {
|
|
||||||
needs: ['header'],
|
|
||||||
itemController: "notification"
|
|
||||||
});
|
|
@ -11,13 +11,10 @@ var notificationFixture = {
|
|||||||
};
|
};
|
||||||
var postUrlStub = "post-url-stub";
|
var postUrlStub = "post-url-stub";
|
||||||
|
|
||||||
module("Discourse.NotificationController", {
|
module("controller:notification", {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
sinon.stub(Discourse.Utilities, "postUrl").returns(postUrlStub);
|
sinon.stub(Discourse.Utilities, "postUrl").returns(postUrlStub);
|
||||||
|
controller = testController('notification', notificationFixture);
|
||||||
controller = Discourse.NotificationController.create({
|
|
||||||
content: notificationFixture
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
teardown: function() {
|
teardown: function() {
|
||||||
|
@ -10,16 +10,14 @@ var noItemsMessageSelector = "div.none";
|
|||||||
var itemListSelector = "ul";
|
var itemListSelector = "ul";
|
||||||
var itemSelector = "li";
|
var itemSelector = "li";
|
||||||
|
|
||||||
module("Discourse.NotificationsController", {
|
module("controller:notifications", {
|
||||||
setup: function() {
|
setup: function() {
|
||||||
sinon.stub(I18n, "t", function (scope, options) {
|
sinon.stub(I18n, "t", function (scope, options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
return [scope, options.username, options.link].join(" ").trim();
|
return [scope, options.username, options.link].join(" ").trim();
|
||||||
});
|
});
|
||||||
|
|
||||||
controller = Discourse.NotificationsController.create({
|
controller = testController('notifications');
|
||||||
container: Discourse.__container__
|
|
||||||
});
|
|
||||||
|
|
||||||
view = Ember.View.create({
|
view = Ember.View.create({
|
||||||
container: Discourse.__container__,
|
container: Discourse.__container__,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* global asyncTest */
|
/* global asyncTest, requirejs, require */
|
||||||
/* exported integration, testController, controllerFor, asyncTestDiscourse, fixture */
|
/* exported integration, testController, controllerFor, asyncTestDiscourse, fixture */
|
||||||
function integration(name, lifecycle) {
|
function integration(name, lifecycle) {
|
||||||
module("Integration: " + name, {
|
module("Integration: " + name, {
|
||||||
@ -25,6 +25,15 @@ function integration(name, lifecycle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testController(klass, model) {
|
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__});
|
return klass.create({model: model, container: Discourse.__container__});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user