FIX: Allow silenced users to like / bookmark, just not flag.

This commit is contained in:
Robin Ward 2018-08-17 11:06:01 -04:00
parent 37d4f27c44
commit a83f662492
2 changed files with 5 additions and 3 deletions

View File

@ -37,8 +37,8 @@ module PostGuardian
result = if authenticated? && post && !@user.anonymous?
# Silenced users can't act on posts
return false if @user.silenced?
# Silenced users can't flag
return false if is_flag && @user.silenced?
# post made by staff, but we don't allow staff flags
return false if is_flag &&

View File

@ -104,9 +104,11 @@ describe Guardian do
expect(Guardian.new(user).post_can_act?(post, :like)).to be_falsey
end
it "returns false when the user is silenced" do
it "works as expected for silenced users" do
UserSilencer.silence(user, admin)
expect(Guardian.new(user).post_can_act?(post, :spam)).to be_falsey
expect(Guardian.new(user).post_can_act?(post, :like)).to be_truthy
expect(Guardian.new(user).post_can_act?(post, :bookmark)).to be_truthy
end
it "allows flagging archived posts" do