ancestries

moves to ancestry from acts_as_commentable_with_threading
This commit is contained in:
Juanjo Bazán
2015-09-02 19:23:09 +02:00
parent 3eae5dff1f
commit dee2d0196b
13 changed files with 59 additions and 57 deletions

View File

@@ -25,24 +25,22 @@ describe Comment do
parent = comment
3.times do
create(:comment, commentable: debate).
move_to_child_of(parent)
create(:comment, commentable: debate, parent: parent)
parent = parent.children.first
end
expect(comment.children_count).to eq(1)
expect(debate.comment_threads.count).to eq(4)
expect(debate.comments.count).to eq(4)
end
it "should increase children count" do
expect do
create(:comment, commentable: debate).
move_to_child_of(comment)
create(:comment, commentable: debate, parent: comment)
end.to change { comment.children_count }.from(0).to(1)
end
it "should decrease children count" do
new_comment = create(:comment, commentable: debate).move_to_child_of(comment)
new_comment = create(:comment, commentable: debate, parent: comment)
expect { new_comment.destroy }.to change { comment.children_count }.from(1).to(0)
end