A platform for community discussion. Free, open, simple.
FIX: Couldn't like staff when `allow_flagging_staff` was set
Robin Wardb4aa0b096ee0
diff --git a/lib/guardian/post_guardian.rb b/lib/guardian/post_guardian.rbindex aa92423b57c..4344e5fd34f 100644--- a/lib/guardian/post_guardian.rb+++ b/lib/guardian/post_guardian.rb@@ -22,7 +22,9 @@ module PostGuardianresult = if authenticated? && post && [email protected]?# post made by staff, but we don't allow staff flags- return false if !SiteSetting.allow_flagging_staff? && post.user.staff?+ return false if is_flag &&+ (!SiteSetting.allow_flagging_staff?) &&+ post.user.staff?return false if [:notify_user, :notify_moderators].include?(action_key) &&!SiteSetting.enable_personal_messages?diff --git a/spec/components/guardian_spec.rb b/spec/components/guardian_spec.rbindex 77667c4e014..0fc91d7b792 100644--- a/spec/components/guardian_spec.rb+++ b/spec/components/guardian_spec.rb@@ -83,6 +83,12 @@ describe Guardian doexpect(Guardian.new(user).post_can_act?(staff_post, :spam)).to eq(false)end+ it "allows liking of staff when allow_flagging_staff is false" do+ SiteSetting.allow_flagging_staff = false+ staff_post = Fabricate(:post, user: Fabricate(:moderator))+ expect(Guardian.new(user).post_can_act?(staff_post, :like)).to eq(true)+ end+it "returns false when liking yourself" doexpect(Guardian.new(post.user).post_can_act?(post, :like)).to be_falseyend