mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 05:48:23 +08:00
Support for a new site setting: newuser_spam_host_threshold
. If a new user posts a link
to the same host enough tiles, they will not be able to post the same link again. Additionally, the site will flag all their previous posts with links as spam and they will be instantly hidden via the auto hide workflow.
This commit is contained in:
@ -266,7 +266,7 @@ describe User do
|
||||
|
||||
describe "trust levels" do
|
||||
|
||||
# NOTE be sure to use build to avoid db calls
|
||||
# NOTE be sure to use build to avoid db calls
|
||||
let(:user) { Fabricate.build(:user, trust_level: TrustLevel.levels[:newuser]) }
|
||||
|
||||
it "sets to the default trust level setting" do
|
||||
@ -770,6 +770,31 @@ describe User do
|
||||
end
|
||||
end
|
||||
|
||||
describe "flag_linked_posts_as_spam" do
|
||||
let(:user) { Fabricate(:user) }
|
||||
let!(:admin) { Fabricate(:admin) }
|
||||
let!(:post) { PostCreator.new(user, title: "this topic contains spam", raw: "this post has a link: http://discourse.org").create }
|
||||
let!(:another_post) { PostCreator.new(user, title: "this topic also contains spam", raw: "this post has a link: http://discourse.org/asdfa").create }
|
||||
let!(:post_without_link) { PostCreator.new(user, title: "this topic shouldn't be spam", raw: "this post has no links in it.").create }
|
||||
|
||||
it "has flagged all the user's posts as spam" do
|
||||
user.flag_linked_posts_as_spam
|
||||
|
||||
post.reload
|
||||
post.spam_count.should == 1
|
||||
|
||||
another_post.reload
|
||||
another_post.spam_count.should == 1
|
||||
|
||||
post_without_link.reload
|
||||
post_without_link.spam_count.should == 0
|
||||
|
||||
# It doesn't raise an exception if called again
|
||||
user.flag_linked_posts_as_spam
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'update_time_read!' do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
Reference in New Issue
Block a user