A staff member can hide another staff's member's post by flagging

This commit is contained in:
Robin Ward 2018-03-20 09:38:23 -04:00
parent d0e7898fa0
commit b39fbf7187
2 changed files with 19 additions and 2 deletions

View File

@ -542,7 +542,8 @@ SQL
end end
def self.auto_hide_if_needed(acting_user, post, post_action_type) def self.auto_hide_if_needed(acting_user, post, post_action_type)
return if post.hidden || post.user.staff? return if post.hidden?
return if (!acting_user.staff?) && post.user.staff?
if post_action_type == :spam && if post_action_type == :spam &&
acting_user.has_trust_level?(TrustLevel[3]) && acting_user.has_trust_level?(TrustLevel[3]) &&

View File

@ -382,7 +382,7 @@ describe PostAction do
expect(post.spam_count).to eq(0) expect(post.spam_count).to eq(0)
end end
it "will not auto hide staff posts" do it "will not allow regular users to auto hide staff posts" do
mod = Fabricate(:moderator) mod = Fabricate(:moderator)
post = Fabricate(:post, user: mod) post = Fabricate(:post, user: mod)
@ -398,6 +398,22 @@ describe PostAction do
expect(post.hidden_at).to be_blank expect(post.hidden_at).to be_blank
end end
it "allows staff users to auto hide staff posts" do
mod = Fabricate(:moderator)
post = Fabricate(:post, user: mod)
SiteSetting.flags_required_to_hide_post = 2
Discourse.stubs(:site_contact_user).returns(admin)
PostAction.act(eviltrout, post, PostActionType.types[:spam])
PostAction.act(Fabricate(:admin), post, PostActionType.types[:spam])
post.reload
expect(post.hidden).to eq(true)
expect(post.hidden_at).to be_present
end
it 'should follow the rules for automatic hiding workflow' do it 'should follow the rules for automatic hiding workflow' do
post = create_post post = create_post
walterwhite = Fabricate(:walter_white) walterwhite = Fabricate(:walter_white)