adapt report spec for the moderator
This commit is contained in:
parent
0b420d0308
commit
098c30c2b7
1 changed files with 45 additions and 3 deletions
|
|
@ -71,7 +71,7 @@ describe ReportController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "mark comment report as user" do
|
context "mark comment report as user" do
|
||||||
it "is behind redirect_unless_admin" do
|
it "is behind redirect_unless_admin_or_moderator" do
|
||||||
put :update, id: @comment.id, type: "comment"
|
put :update, id: @comment.id, type: "comment"
|
||||||
expect(response).to redirect_to stream_path
|
expect(response).to redirect_to stream_path
|
||||||
expect(Report.where(reviewed: false, item_id: @comment.id, item_type: "comment")).to be_truthy
|
expect(Report.where(reviewed: false, item_id: @comment.id, item_type: "comment")).to be_truthy
|
||||||
|
|
@ -98,18 +98,39 @@ describe ReportController, type: :controller do
|
||||||
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "comment")).to be_truthy
|
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "comment")).to be_truthy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "mark post report as moderator" do
|
||||||
|
before do
|
||||||
|
Role.add_moderator(alice.person)
|
||||||
|
end
|
||||||
|
it "succeeds" do
|
||||||
|
put :update, id: @message.id, type: "post"
|
||||||
|
expect(response.status).to eq(302)
|
||||||
|
expect(Report.where(reviewed: true, item_id: @message.id, item_type: "post")).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
context "mark comment report as moderator" do
|
||||||
|
before do
|
||||||
|
Role.add_moderator(alice.person)
|
||||||
|
end
|
||||||
|
it "succeeds" do
|
||||||
|
put :update, id: @comment.id, type: "comment"
|
||||||
|
expect(response.status).to eq(302)
|
||||||
|
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "comment")).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#destroy" do
|
describe "#destroy" do
|
||||||
context "destroy post as user" do
|
context "destroy post as user" do
|
||||||
it "is behind redirect_unless_admin" do
|
it "is behind redirect_unless_admin_or_moderator" do
|
||||||
delete :destroy, id: @message.id, type: "post"
|
delete :destroy, id: @message.id, type: "post"
|
||||||
expect(response).to redirect_to stream_path
|
expect(response).to redirect_to stream_path
|
||||||
expect(Report.where(reviewed: false, item_id: @message.id, item_type: "post")).to be_truthy
|
expect(Report.where(reviewed: false, item_id: @message.id, item_type: "post")).to be_truthy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
context "destroy comment as user" do
|
context "destroy comment as user" do
|
||||||
it "is behind redirect_unless_admin" do
|
it "is behind redirect_unless_admin_or_moderator" do
|
||||||
delete :destroy, id: @comment.id, type: "comment"
|
delete :destroy, id: @comment.id, type: "comment"
|
||||||
expect(response).to redirect_to stream_path
|
expect(response).to redirect_to stream_path
|
||||||
expect(Report.where(reviewed: false, item_id: @comment.id, item_type: "comment")).to be_truthy
|
expect(Report.where(reviewed: false, item_id: @comment.id, item_type: "comment")).to be_truthy
|
||||||
|
|
@ -136,5 +157,26 @@ describe ReportController, type: :controller do
|
||||||
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "comment")).to be_truthy
|
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "comment")).to be_truthy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "destroy post as moderator" do
|
||||||
|
before do
|
||||||
|
Role.add_moderator(alice.person)
|
||||||
|
end
|
||||||
|
it "succeeds" do
|
||||||
|
delete :destroy, id: @message.id, type: "post"
|
||||||
|
expect(response.status).to eq(302)
|
||||||
|
expect(Report.where(reviewed: true, item_id: @message.id, item_type: "post")).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
context "destroy comment as moderator" do
|
||||||
|
before do
|
||||||
|
Role.add_moderator(alice.person)
|
||||||
|
end
|
||||||
|
it "succeeds" do
|
||||||
|
delete :destroy, id: @comment.id, type: "comment"
|
||||||
|
expect(response.status).to eq(302)
|
||||||
|
expect(Report.where(reviewed: true, item_id: @comment.id, item_type: "comment")).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue