Fix #5013: BUR model doesn't validate tags.

Don't allow users to request aliases, implications, or renames for invalid tag names.

As a side effect, it's no longer possible to request shortcut aliases like
`/hr -> hakurei_reimu` (slash abbreviations still exist, but they can't
be overridden with aliases). Tests involving these types of aliases are
removed.
This commit is contained in:
evazion
2022-04-30 19:25:18 -05:00
parent 0920d2ca24
commit ccd0dde081
10 changed files with 66 additions and 31 deletions

View File

@@ -26,8 +26,8 @@ class TagRelationship < ApplicationRecord
before_validation :normalize_names
validates :status, inclusion: { in: STATUSES }
validates :antecedent_name, presence: true
validates :consequent_name, presence: true
validates :antecedent_name, presence: true, tag_name: true, if: :antecedent_name_changed?
validates :consequent_name, presence: true, tag_name: true, if: :consequent_name_changed?
validates :approver, presence: { message: "must exist" }, if: -> { approver_id.present? }
validates :forum_topic, presence: { message: "must exist" }, if: -> { forum_topic_id.present? }
validate :antecedent_and_consequent_are_different