BUGFIX: deleted categories would mess up watching/tracking prefs
This commit is contained in:
parent
43c698282c
commit
612001aa74
|
@ -209,9 +209,14 @@ Discourse.Category.reopenClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
findByIds: function(ids){
|
findByIds: function(ids){
|
||||||
return ids.map(function(id){
|
var categories = [];
|
||||||
return Discourse.Category.findById(id);
|
_.each(ids, function(id){
|
||||||
|
var found = Discourse.Category.findById(id);
|
||||||
|
if(found){
|
||||||
|
categories.push(found);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
return categories;
|
||||||
},
|
},
|
||||||
|
|
||||||
findBySlug: function(slug, parentSlug) {
|
findBySlug: function(slug, parentSlug) {
|
||||||
|
|
|
@ -39,6 +39,15 @@ test('findBySlug', function() {
|
||||||
blank(Discourse.Category.findBySlug('luke', 'leia'), 'luke is blank with an incorrect parent');
|
blank(Discourse.Category.findBySlug('luke', 'leia'), 'luke is blank with an incorrect parent');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('findByIds', function(){
|
||||||
|
var categories = [
|
||||||
|
Discourse.Category.create({id: 1}),
|
||||||
|
Discourse.Category.create({id: 2})];
|
||||||
|
|
||||||
|
this.stub(Discourse.Category, 'list').returns(categories);
|
||||||
|
deepEqual(Discourse.Category.findByIds([1,2,3]), categories);
|
||||||
|
});
|
||||||
|
|
||||||
test('postCountStats', function() {
|
test('postCountStats', function() {
|
||||||
var category1 = Discourse.Category.create({id: 1, slug: 'unloved', posts_year: 2, posts_month: 0, posts_week: 0, posts_day: 0}),
|
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}),
|
category2 = Discourse.Category.create({id: 2, slug: 'hasbeen', posts_year: 50, posts_month: 4, posts_week: 0, posts_day: 0}),
|
||||||
|
|
Loading…
Reference in New Issue