1 # frozen_string_literal: true
5 class SpamScorerTest < ActiveSupport::TestCase
6 def test_html_spam_score
7 r = RichText.new("html", "foo <a href='http://example.com/'>bar</a> baz")
8 scorer = SpamScorer.new_from_rich_text(r)
9 assert_equal 55, scorer.score.round
12 def test_markdown_spam_score
13 r = RichText.new("markdown", "foo [bar](http://example.com/) baz")
14 scorer = SpamScorer.new_from_rich_text(r)
15 assert_equal 50, scorer.score.round
18 def test_text_spam_score
19 r = RichText.new("text", "foo http://example.com/ bar")
20 scorer = SpamScorer.new_from_rich_text(r)
21 assert_equal 141, scorer.score.round
24 def test_user_spam_score
25 user = build(:user, :description => "foo [bar](http://example.com/) baz")
26 scorer = SpamScorer.new_from_user(user)
27 assert_equal 12, scorer.score
30 def test_spammy_phrases
31 create(:spammy_phrase, :phrase => "Business Description:")
32 create(:spammy_phrase, :phrase => "Additional Keywords:")
33 create(:spammy_phrase, :phrase => "Große Preise")
34 create(:spammy_phrase, :phrase => "Relevant Experience:")
38 BUSINESS DESCRIPTION: totally legit beesknees.
39 Additional Keywords: apiary joints.
40 GROSSE PREISE: VIEL GELD.
41 RELEVANT EⅩPERIENCE: disguising latin characters as roman numerals.
44 scorer = SpamScorer.new_from_rich_text(r)
45 assert_equal 160, scorer.score.round