adds specs

This commit is contained in:
rgarcia
2015-09-05 22:02:02 +02:00
parent 0bca1c5b95
commit 9515ccc3a8
3 changed files with 81 additions and 0 deletions

View File

@@ -36,4 +36,34 @@ describe Comment do
expect(comment).to be_as_moderator
end
end
describe "cache" do
let(:comment) { create(:comment) }
it "should expire cache when it has a new vote" do
expect { create(:vote, votable: comment) }
.to change { comment.updated_at }
end
it "should expire cache when hidden" do
expect { comment.hide }
.to change { comment.updated_at }
end
it "should expire cache when the author is hidden" do
expect { comment.user.hide }
.to change { comment.reload.updated_at }
end
it "should expire cache when the author changes" do
expect { comment.user.update(username: "Isabel") }
.to change { comment.reload.updated_at }
end
it "should expire cache when the author's organization get verified" do
create(:organization, user: comment.user)
expect { comment.user.organization.verify }
.to change { comment.reload.updated_at}
end
end
end