adds specs
This commit is contained in:
@@ -36,4 +36,34 @@ describe Comment do
|
|||||||
expect(comment).to be_as_moderator
|
expect(comment).to be_as_moderator
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|||||||
@@ -268,4 +268,34 @@ describe Debate do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "cache" do
|
||||||
|
let(:debate) { create(:debate) }
|
||||||
|
|
||||||
|
it "should expire cache when it has a new comment" do
|
||||||
|
expect { create(:comment, commentable: debate) }
|
||||||
|
.to change { debate.updated_at }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expire cache when it has a new vote" do
|
||||||
|
expect { create(:vote, votable: debate) }
|
||||||
|
.to change { debate.updated_at }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expire cache when it has a new tag" do
|
||||||
|
expect { debate.update(tag_list: "new tag") }
|
||||||
|
.to change { debate.updated_at }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expire cache when its author changes" do
|
||||||
|
expect { debate.author.update(username: "Eva") }
|
||||||
|
.to change { debate.reload.updated_at }
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expire cache when the author's organization get verified" do
|
||||||
|
create(:organization, user: debate.author)
|
||||||
|
expect { debate.author.organization.verify }
|
||||||
|
.to change { debate.reload.updated_at}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -299,4 +299,25 @@ describe User do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "cache" do
|
||||||
|
let(:user) { create(:user) }
|
||||||
|
|
||||||
|
it "should expire cache with becoming a moderator" do
|
||||||
|
expect { create(:moderator, user: user) }
|
||||||
|
.to change { user.updated_at}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expire cache with becoming an admin" do
|
||||||
|
expect { create(:administrator, user: user) }
|
||||||
|
.to change { user.updated_at}
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expire cache with becoming a veridied organization" do
|
||||||
|
create(:organization, user: user)
|
||||||
|
expect { user.organization.verify }
|
||||||
|
.to change { user.reload.updated_at}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user