FIX: admins bypass some post validations. This allows them to edit legal docs even if those docs are longer than max post length, for example.

This commit is contained in:
Neil Lalonde
2014-07-28 16:40:06 -04:00
parent 81ff121fe8
commit e1be478ef4
4 changed files with 67 additions and 9 deletions

View File

@ -3,14 +3,16 @@ module Validators; end
class Validators::PostValidator < ActiveModel::Validator
def validate(record)
presence(record)
stripped_length(record)
raw_quality(record)
max_posts_validator(record)
max_mention_validator(record)
max_images_validator(record)
max_attachments_validator(record)
max_links_validator(record)
unique_post_validator(record)
unless record.acting_user.try(:admin?)
stripped_length(record)
raw_quality(record)
max_posts_validator(record)
max_mention_validator(record)
max_images_validator(record)
max_attachments_validator(record)
max_links_validator(record)
unique_post_validator(record)
end
end
def presence(post)