FIX: Highlighting was not being applied after some rendering.

Also includes a bunch of ES6 stuff.
This commit is contained in:
Robin Ward
2015-02-12 15:37:02 -05:00
parent 96697c7957
commit a519fd5bcf
21 changed files with 314 additions and 503 deletions
@@ -3,8 +3,10 @@ moduleFor('controller:topic', 'controller:topic', {
'controller:search', 'controller:topic-progress', 'controller:application']
});
import Topic from 'discourse/models/topic';
var buildTopic = function() {
return Discourse.Topic.create({
return Topic.create({
title: "Qunit Test Topic",
participants: [
{id: 1234,
@@ -1,5 +1,7 @@
module("Discourse.SelectedPostsCount");
import Topic from 'discourse/models/topic';
var buildTestObj = function(params) {
return Ember.Object.createWithMixins(Discourse.SelectedPostsCount, params || {});
};
@@ -26,7 +28,7 @@ test("when all posts are selected and there is a posts_count", function() {
test("when all posts are selected and there is topic with a posts_count", function() {
var testObj = buildTestObj({
allPostsSelected: true,
topic: Discourse.Topic.create({ posts_count: 3456 })
topic: Topic.create({ posts_count: 3456 })
});
equal(testObj.get('selectedPostsCount'), 3456, "It returns the topic's posts_count");
@@ -1,7 +1,10 @@
module("Discourse.PostStream");
module("model:post-stream");
import PostStream from 'discourse/models/post-stream';
import Topic from 'discourse/models/topic';
var buildStream = function(id, stream) {
var topic = Discourse.Topic.create({id: id, chunk_size: 5});
var topic = Topic.create({id: id, chunk_size: 5});
var ps = topic.get('postStream');
if (stream) {
ps.set('stream', stream);
@@ -12,7 +15,7 @@ var buildStream = function(id, stream) {
var participant = {username: 'eviltrout'};
test('create', function() {
ok(Discourse.PostStream.create(), 'it can be created with no parameters');
ok(PostStream.create(), 'it can be created with no parameters');
});
test('defaults', function() {
@@ -1,7 +1,9 @@
module("Discourse.TopicDetails");
module("model:topic-details");
import Topic from 'discourse/models/topic';
var buildDetails = function(id) {
var topic = Discourse.Topic.create({id: id});
var topic = Topic.create({id: id});
return topic.get('details');
};
@@ -20,13 +22,9 @@ test('updateFromJson', function() {
});
equal(details.get('suggested_topics.length'), 2, 'it loaded the suggested_topics');
containsInstance(details.get('suggested_topics'), Discourse.Topic);
containsInstance(details.get('suggested_topics'), Topic);
equal(details.get('allowed_users.length'), 1, 'it loaded the allowed users');
containsInstance(details.get('allowed_users'), Discourse.User);
});
+10 -8
View File
@@ -1,20 +1,22 @@
module("Discourse.Topic");
module("model:topic");
import Topic from 'discourse/models/topic';
test("defaults", function() {
var topic = Discourse.Topic.create({id: 1234});
var topic = Topic.create({id: 1234});
blank(topic.get('deleted_at'), 'deleted_at defaults to blank');
blank(topic.get('deleted_by'), 'deleted_by defaults to blank');
});
test('has details', function() {
var topic = Discourse.Topic.create({id: 1234});
var topic = Topic.create({id: 1234});
var topicDetails = topic.get('details');
present(topicDetails, "a topic has topicDetails after we create it");
equal(topicDetails.get('topic'), topic, "the topicDetails has a reference back to the topic");
});
test('has a postStream', function() {
var topic = Discourse.Topic.create({id: 1234});
var topic = Topic.create({id: 1234});
var postStream = topic.get('postStream');
present(postStream, "a topic has a postStream after we create it");
equal(postStream.get('topic'), topic, "the postStream has a reference back to the topic");
@@ -24,13 +26,13 @@ test('has a postStream', function() {
test('category relationship', function() {
// It finds the category by id
var category = Discourse.Category.list()[0],
topic = Discourse.Topic.create({id: 1111, category_id: category.get('id') });
topic = Topic.create({id: 1111, category_id: category.get('id') });
equal(topic.get('category'), category);
});
test("updateFromJson", function() {
var topic = Discourse.Topic.create({id: 1234}),
var topic = Topic.create({id: 1234}),
category = Discourse.Category.list()[0];
topic.updateFromJson({
@@ -48,7 +50,7 @@ test("updateFromJson", function() {
test("destroy", function() {
var user = Discourse.User.create({username: 'eviltrout'});
var topic = Discourse.Topic.create({id: 1234});
var topic = Topic.create({id: 1234});
sandbox.stub(Discourse, 'ajax');
@@ -60,7 +62,7 @@ test("destroy", function() {
test("recover", function() {
var user = Discourse.User.create({username: 'eviltrout'});
var topic = Discourse.Topic.create({id: 1234, deleted_at: new Date(), deleted_by: user});
var topic = Topic.create({id: 1234, deleted_at: new Date(), deleted_by: user});
sandbox.stub(Discourse, 'ajax');