mirror of
https://github.com/discourse/discourse.git
synced 2025-02-06 11:28:18 +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() {
|
||||
return "notifications." + Discourse.Site.currentProp("notificationLookup")[this.get("notification_type")];
|
||||
}.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";
|
||||
|
||||
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() {
|
||||
|
@ -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__,
|
||||
|
@ -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__});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user