PostSetPresenters::Post#related_posts: clean up metatag parsing (#2894).

* Fix `#related_tags` to use `Tag.has_metatag?`.
* Fix Tag::SUBQUERY_METATAGS and Tag::METATAGS to be arrays instead of regexes.
This commit is contained in:
evazion
2018-09-20 14:42:10 -05:00
parent 6fe883c316
commit 29cdaddd86
5 changed files with 18 additions and 10 deletions

View File

@@ -21,7 +21,7 @@ class TagNameValidator < ActiveModel::EachValidator
record.errors[attribute] << "'#{value}' cannot contain non-printable characters"
when /[^[[:ascii:]]]/
record.errors[attribute] << "'#{value}' must consist of only ASCII characters"
when /\A(#{Tag::METATAGS}|#{Tag::SUBQUERY_METATAGS}):(.+)\z/i
when /\A(#{Regexp.union(Tag::METATAGS)}):(.+)\z/i
record.errors[attribute] << "'#{value}' cannot begin with '#{$1}:'"
when /\A(#{Tag.categories.regexp}):(.+)\z/i
record.errors[attribute] << "'#{value}' cannot begin with '#{$1}:'"