mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 19:00:32 -06:00
FIX: blocking users should never hide all posts if they are trust level 1 or higher
This commit is contained in:
parent
2d859ba0ed
commit
06eb256d0a
@ -26,6 +26,8 @@ class UserBlocker
|
||||
end
|
||||
|
||||
def hide_posts
|
||||
return unless @user.trust_level == TrustLevel[0]
|
||||
|
||||
Post.where(user_id: @user.id).update_all(["hidden = true, hidden_reason_id = COALESCE(hidden_reason_id, ?)", Post.hidden_reasons[:new_user_spam_threshold_reached]])
|
||||
topic_ids = Post.where(user_id: @user.id, post_number: 1).pluck(:topic_id)
|
||||
Topic.where(id: topic_ids).update_all(visible: false) unless topic_ids.empty?
|
||||
|
@ -27,8 +27,6 @@ describe UserBlocker do
|
||||
SystemMessage.expects(:create).with(user, :blocked_by_staff).returns(true)
|
||||
UserBlocker.block(user, Fabricate.build(:admin))
|
||||
end
|
||||
|
||||
# TODO: it 'logs the action'
|
||||
end
|
||||
|
||||
context 'not given a staff user argument' do
|
||||
@ -83,12 +81,10 @@ describe UserBlocker do
|
||||
SystemMessage.expects(:create).never
|
||||
unblock_user
|
||||
end
|
||||
|
||||
# TODO: it 'logs the action'
|
||||
end
|
||||
|
||||
describe 'hide_posts' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let(:user) { Fabricate(:user, trust_level: 0) }
|
||||
let!(:post) { Fabricate(:post, user: user) }
|
||||
subject { UserBlocker.new(user) }
|
||||
|
||||
@ -101,6 +97,13 @@ describe UserBlocker do
|
||||
subject.block
|
||||
expect(post.topic.reload).to_not be_visible
|
||||
end
|
||||
|
||||
it "doesn't hide posts if user is TL1" do
|
||||
user.trust_level = 1
|
||||
subject.block
|
||||
expect(post.reload).to_not be_hidden
|
||||
expect(post.topic.reload).to be_visible
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user