Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add post validations also to suggested edits (301, 764, 765) #1136

Merged

Conversation

Taeir
Copy link
Contributor

@Taeir Taeir commented Jul 21, 2023

Separates out shared post validations to a concern and adds this concern on both Post and SuggestedEdit. This means that the validations will be in line between them. Some validations remain in Post as they are specific to posts (moderator_tags should not be checked on suggested edits, see #741).

I also fixed some (as far as I know) unreported issues with the validations not working as intended:

  1. Fixed: it is no longer possible to have no title on a post type that doesn't support tags
  2. Fixed: it is no longer possible to have no body on a post type that doesn't support tags
  3. Fixed: it is no longer possible to have a body which is far shorter than the configured minimum due to the HTML added (now uses body_markdown)

I have altered the if statements on the validations for title and body length as those can be nil for suggested edits (means no change suggested for them). This is not a problem for posts, because other validations on Post already catch when they are empty.

Fixes #301
Fixes #764
Fixes #765

PostValidations are defined now as the shared validations between posts
and suggested edits.

For checking the minimum body length, I switched it to checking the
markdown body as that is a much better representation of the length. In
my testing even a body with just "Hello" ended up being long enough
after all the html that was added.

I have altered the if statements on the validations for title and body
length as those can be nil for suggested edits. This is not a problem,
because other validations on Post already catch when they are empty.

Additionally, the title and body were only extensively checked if the
post type supported tags. I have now changed that such that title and
body are always required for posts.
@Taeir Taeir marked this pull request as ready for review July 21, 2023 17:45
@cellio cellio requested a review from a team July 21, 2023 19:56
@ArtOfCode- ArtOfCode- merged commit 2a4e61b into codidact:develop Aug 1, 2023
1 check passed
@Taeir Taeir deleted the 301-edit-suggestions-with-too-many-tags branch August 1, 2023 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants