FEATURE: New site setting, allow staff flags, false by default

For some large communities, it makes sense to disable flagging of
staff posts.
This commit is contained in:
Robin Ward
2018-02-12 14:56:21 -05:00
parent d962d6072e
commit 6287631745
4 changed files with 18 additions and 1 deletions

View File

@ -66,11 +66,23 @@ describe Guardian do
expect(Guardian.new(user).post_can_act?(post, :like)).to be_falsey
end
it "always allows flagging" do
it "allows flagging archived posts" do
post.topic.archived = true
expect(Guardian.new(user).post_can_act?(post, :spam)).to be_truthy
end
it "allows flagging of staff posts when allow_staff_flags is true" do
SiteSetting.allow_staff_flags = true
staff_post = Fabricate(:post, user: Fabricate(:moderator))
expect(Guardian.new(user).post_can_act?(staff_post, :spam)).to be_truthy
end
it "doesn't allow flagging of staff posts when allow_staff_flags is false" do
SiteSetting.allow_staff_flags = false
staff_post = Fabricate(:post, user: Fabricate(:moderator))
expect(Guardian.new(user).post_can_act?(staff_post, :spam)).to eq(false)
end
it "returns false when liking yourself" do
expect(Guardian.new(post.user).post_can_act?(post, :like)).to be_falsey
end