Show topic and post counts by day/week/month/year on categories page

This commit is contained in:
Neil Lalonde
2013-12-13 15:15:51 -05:00
parent a7a7387da1
commit 49c3482464
10 changed files with 182 additions and 14 deletions

View File

@@ -37,4 +37,31 @@ test('findBySlug', function() {
equal(Discourse.Category.findBySlug('luke', 'darth'), luke, 'we can find a child with parent');
blank(Discourse.Category.findBySlug('luke'), 'luke is blank without the parent');
blank(Discourse.Category.findBySlug('luke', 'leia'), 'luke is blank with an incorrect parent');
});
});
test('postCountStatsStrings', function() {
var category1 = Discourse.Category.create({id: 1, slug: 'unloved', posts_year: 2, posts_month: 0, posts_week: 0, posts_day: 0}),
category2 = Discourse.Category.create({id: 2, slug: 'hasbeen', posts_year: 50, posts_month: 4, posts_week: 0, posts_day: 0}),
category3 = Discourse.Category.create({id: 3, slug: 'solastweek', posts_year: 250, posts_month: 200, posts_week: 50, posts_day: 0}),
category4 = Discourse.Category.create({id: 4, slug: 'hotstuff', posts_year: 500, posts_month: 280, posts_week: 100, posts_day: 22});
var result = category1.get('postCountStatsStrings');
equal(result.length, 2, "should show month and year");
equal(result[0], '0 / month', "should show month and year");
equal(result[1], '2 / year', "should show month and year");
result = category2.get('postCountStatsStrings');
equal(result.length, 2, "should show month and year");
equal(result[0], '4 / month', "should show month and year");
equal(result[1], '50 / year', "should show month and year");
result = category3.get('postCountStatsStrings');
equal(result.length, 2, "should show week and month");
equal(result[0], '50 / week', "should show week and month");
equal(result[1], '200 / month', "should show week and month");
result = category4.get('postCountStatsStrings');
equal(result.length, 2, "should show day and week");
equal(result[0], '22 / day', "should show day and week");
equal(result[1], '100 / week', "should show day and week");
});