mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Fixes issues with composer
This commit is contained in:
@@ -1,54 +1,56 @@
|
||||
import Site from 'discourse/models/site';
|
||||
|
||||
const notificationFixture = {
|
||||
notification_type: 1, //mentioned
|
||||
post_number: 1,
|
||||
topic_id: 1234,
|
||||
slug: "a-slug",
|
||||
data: {
|
||||
topic_title: "some title",
|
||||
display_username: "velesin"
|
||||
},
|
||||
site: Site.current()
|
||||
};
|
||||
function buildFixture() {
|
||||
return {
|
||||
notification_type: 1, //mentioned
|
||||
post_number: 1,
|
||||
topic_id: 1234,
|
||||
slug: "a-slug",
|
||||
data: {
|
||||
topic_title: "some title",
|
||||
display_username: "velesin"
|
||||
},
|
||||
site: Site.current()
|
||||
};
|
||||
}
|
||||
|
||||
moduleFor("controller:notification");
|
||||
|
||||
test("scope property is correct", function() {
|
||||
const controller = this.subject(notificationFixture);
|
||||
const controller = this.subject(buildFixture());
|
||||
equal(controller.get("scope"), "notifications.mentioned");
|
||||
});
|
||||
|
||||
test("username property is correct", function() {
|
||||
const controller = this.subject(notificationFixture);
|
||||
const controller = this.subject(buildFixture());
|
||||
equal(controller.get("username"), "velesin");
|
||||
});
|
||||
|
||||
test("description property returns badge name when there is one", function() {
|
||||
const fixtureWithBadgeName = _.extend({}, notificationFixture, { data: { badge_name: "badge" } });
|
||||
const fixtureWithBadgeName = _.extend({}, buildFixture(), { data: { badge_name: "badge" } });
|
||||
const controller = this.subject(fixtureWithBadgeName);
|
||||
equal(controller.get("description"), "badge");
|
||||
});
|
||||
|
||||
test("description property returns empty string when there is no topic title", function() {
|
||||
const fixtureWithEmptyTopicTitle = _.extend({}, notificationFixture, { data: { topic_title: "" } });
|
||||
const fixtureWithEmptyTopicTitle = _.extend({}, buildFixture(), { data: { topic_title: "" } });
|
||||
const controller = this.subject(fixtureWithEmptyTopicTitle);
|
||||
equal(controller.get("description"), "");
|
||||
});
|
||||
|
||||
test("description property returns topic title", function() {
|
||||
const fixtureWithTopicTitle = _.extend({}, notificationFixture, { data: { topic_title: "topic" } });
|
||||
const fixtureWithTopicTitle = _.extend({}, buildFixture(), { data: { topic_title: "topic" } });
|
||||
const controller = this.subject(fixtureWithTopicTitle);
|
||||
equal(controller.get("description"), "topic");
|
||||
});
|
||||
|
||||
test("url property returns badge's url when there is a badge", function() {
|
||||
const fixtureWithBadge = _.extend({}, notificationFixture, { data: { badge_id: 1, badge_name: "Badge Name"} });
|
||||
const fixtureWithBadge = _.extend({}, buildFixture(), { data: { badge_id: 1, badge_name: "Badge Name"} });
|
||||
const controller = this.subject(fixtureWithBadge);
|
||||
equal(controller.get("url"), "/badges/1/badge-name");
|
||||
});
|
||||
|
||||
test("url property returns topic's url when there is a topic", function() {
|
||||
const controller = this.subject(notificationFixture);
|
||||
const controller = this.subject(buildFixture());
|
||||
equal(controller.get("url"), "/t/a-slug/1234");
|
||||
});
|
||||
|
||||
@@ -70,6 +70,8 @@ function acceptance(name, options) {
|
||||
if (options && options.teardown) {
|
||||
options.teardown.call(this);
|
||||
}
|
||||
Discourse.User.resetCurrent();
|
||||
Discourse.Site.resetCurrent(Discourse.Site.create(fixtures['site.json'].site));
|
||||
|
||||
Discourse.Utilities.avatarImg = oldAvatar;
|
||||
Discourse.reset();
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
var asianCategory = Discourse.Category.create({name: '确实是这样', id: 343434});
|
||||
|
||||
module("Discourse.NavItem", {
|
||||
setup: function() {
|
||||
Ember.run(function() {
|
||||
const asianCategory = Discourse.Category.create({name: '确实是这样', id: 343434});
|
||||
Discourse.Site.currentProp('categories').addObject(asianCategory);
|
||||
});
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
Em.run(function() {
|
||||
Discourse.Site.currentProp('categories').removeObject(asianCategory);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user