Commit graph

3 commits

Author SHA1 Message Date
Mac Siri
842e6880b8
Routine rubocop fix on /spec (#19217)
* Softrun rubocop

* Hardrun rubocop (-A)

* Change a rubocop rule

* Add missing cops

* Undo & redo rubocop -A
2023-03-21 09:55:26 -04:00
Jeremy Friesen
29f6853ee9
Refactoring Spam Handler (#15412)
* Refactoring Spam Handler

There's considerable repeated logic between checking spam for an article
and spam for a comment and user.

This attempts to send things through channels that are similar and close
in organization.

* Fixing broken spec

* Fixing spec around recent user

* Update app/models/reaction.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Update app/models/reaction.rb

Co-authored-by: Michael Kohl <citizen428@forem.com>

* Consolidating new user query logic

Prior to this commit there were two separate queries around new user
logic.  With this commit, we're changing the logic to repurpose a site
wide setting.

* Generalizing a previously specific message

* Fixing method name

As part of a recommended refactor, I extracted a method, then renamed
it.  I failed to account for that renaming.

This commit fixes that.

Co-authored-by: Michael Kohl <citizen428@forem.com>
2021-11-30 12:45:12 -05:00
Jeremy Friesen
91b951eb05
Refactoring and extending article spam behavior (#15399)
* Refactoring and extending article spam behavior

Prior to this refactor, we were checking an Article's title for
spaminess.  This change now checks the Article's title and
body_markdown.

In addition, the encapsulates the regular expression implementations in
favor of asking the Settings::RateLimit class to determine if the passed
in text is "spammy".

Furthermore, instead of having lots of inline logic within the article,
this refactor introduces a `Spam::ArticleHandler` class.  This helps
tidy up the already busy Article specs by delegating the business logic
of Spam handling to it's own class.

There are further refactors for Comments and Users that would follow
this pattern, but this change is more important to get out the door.

Closes #15396

* Adding comments to clarify behavior of spam handling

* Adding missing expectation to spec
2021-11-17 17:09:17 -05:00