|
49 | 49 | expect(described_class.should_scan_post?(post)).to eq(false) |
50 | 50 | end |
51 | 51 |
|
| 52 | + it "returns false for bots" do |
| 53 | + post.user.id = -100 |
| 54 | + expect(described_class.should_scan_post?(post)).to eq(false) |
| 55 | + end |
| 56 | + |
| 57 | + it "returns false for staff" do |
| 58 | + post.user.moderator = true |
| 59 | + expect(described_class.should_scan_post?(post)).to eq(false) |
| 60 | + end |
| 61 | + |
52 | 62 | it "returns false for users with many public posts" do |
53 | 63 | Fabricate(:post, user: user, topic: topic) |
54 | 64 | Fabricate(:post, user: user, topic: topic) |
|
207 | 217 | end |
208 | 218 | end |
209 | 219 |
|
| 220 | + it "unsilences flagging user if erronuously silenced" do |
| 221 | + described_class.flagging_user.update!(silenced_till: 1.day.from_now) |
| 222 | + expect(described_class.flagging_user.silenced?).to eq(false) |
| 223 | + end |
| 224 | + |
| 225 | + it "ensures flagging user is tl4" do |
| 226 | + described_class.flagging_user.update!(trust_level: 0) |
| 227 | + expect(described_class.flagging_user.trust_level).to eq(4) |
| 228 | + end |
| 229 | + |
| 230 | + it "unsuspends user if it was erronuously suspended" do |
| 231 | + described_class.flagging_user.update!(suspended_till: 1.day.from_now, suspended_at: 1.day.ago) |
| 232 | + expect(described_class.flagging_user.suspended?).to eq(false) |
| 233 | + end |
| 234 | + |
| 235 | + it "makes sure account is active" do |
| 236 | + described_class.flagging_user.update!(active: false) |
| 237 | + expect(described_class.flagging_user.active).to eq(true) |
| 238 | + end |
| 239 | + |
210 | 240 | describe "integration test" do |
211 | 241 | fab!(:llm_model) |
212 | 242 | let(:api_audit_log) { Fabricate(:api_audit_log) } |
|
243 | 273 | it "correctly handles spam scanning" do |
244 | 274 | expect(described_class.flagging_user.id).not_to eq(Discourse.system_user.id) |
245 | 275 |
|
246 | | - # flag post for scanning |
247 | 276 | post = post_with_uploaded_image |
| 277 | + # this is surprising, core fabricator is not linking |
| 278 | + # we need it linked so we scan uploads |
| 279 | + post.link_post_uploads |
| 280 | + |
| 281 | + expect(described_class.should_scan_post?(post)).to eq(true) |
| 282 | + expect(post.upload_ids).to be_present |
248 | 283 |
|
249 | 284 | described_class.new_post(post) |
250 | 285 |
|
|
0 commit comments