discourse-ai/spec/requests/admin/reviewable_controller_spec.rb
Sam fae2d5ff2c
FEATURE: link correctly to filters to assist in debugging spam (#1031)
- Add spam_score_type to AiSpamSerializer for better integration with reviewables.
- Introduce a custom filter for detecting AI spam false negatives in moderation workflows.
- Refactor spam report generation to improve identification of false negatives.
- Add tests to verify the custom filter and its behavior.
- Introduce links for all spam counts in report
2024-12-17 11:02:18 +11:00

48 lines
1.2 KiB
Ruby

# frozen_string_literal: true
RSpec.describe ReviewablesController do
fab!(:post1) { Fabricate(:post) }
fab!(:post2) { Fabricate(:post) }
fab!(:admin)
fab!(:llm_model)
fab!(:reviewable) do
Reviewable.create!(
target: post1,
topic: post2.topic,
type: ReviewablePost,
created_by: admin,
status: Reviewable.statuses[:pending],
)
end
fab!(:reviewable2) do
Reviewable.create!(
target: post2,
topic: post2.topic,
type: ReviewablePost,
created_by: admin,
status: Reviewable.statuses[:pending],
)
end
fab!(:ai_spam_log_missed) do
AiSpamLog.create!(is_spam: false, post_id: post1.id, llm_model_id: llm_model.id)
end
# we amend the behavior with a custom filter so we need to confirm it works
it "properly applies custom filter" do
sign_in(admin)
get '/review.json?additional_filters={"ai_spam_false_negative":true}'
expect(response.status).to eq(200)
json = JSON.parse(response.body)
expect(json["reviewables"].length).to eq(1)
get "/review.json"
expect(response.status).to eq(200)
json = JSON.parse(response.body)
expect(json["reviewables"].length).to eq(2)
end
end