Skip to content

Commit

Permalink
Added test for dupe parents
Browse files Browse the repository at this point in the history
ensure we do not create a duplicate post/category xref for duplicate
parent categories
  • Loading branch information
danieljsummers committed Aug 30, 2017
1 parent a57f3c1 commit ce337a3
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/scripts/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ describe('Post', () => {
return Post.removeById(post._id);
}));

it('setCategories() - multiple hierarchies (dedupes repeated parent)', () => Post.insert({
source: 'foo.md',
slug: 'bar'
}).then(post => post.setCategories([['foo', 'bar'], ['foo', 'baz']])
.thenReturn(Post.findById(post._id))).then(post => {
var cats = post.categories.toArray();

// There should have been 3 categories set (foo is dupe)
cats.should.have.lengthOf(3);

return Post.removeById(post._id);
}));

it('remove PostTag references when a post is removed', () => Post.insert({
source: 'foo.md',
slug: 'bar'
Expand Down

0 comments on commit ce337a3

Please sign in to comment.