]> cat aescling's git repositories - mastodon.git/commitdiff
Fix featured tag form not failing on failed tag validations (#10167)
authorEugen Rochko <eugen@zeonfederated.com>
Tue, 5 Mar 2019 02:46:24 +0000 (03:46 +0100)
committerGitHub <noreply@github.com>
Tue, 5 Mar 2019 02:46:24 +0000 (03:46 +0100)
app/models/featured_tag.rb

index b5a10ad2da4cc742a828ba415c69348e245f7f9c..d06ae26a8902995bbfaa870812380703ff6b6a44 100644 (file)
@@ -18,11 +18,12 @@ class FeaturedTag < ApplicationRecord
 
   delegate :name, to: :tag, allow_nil: true
 
-  validates :name, presence: true
+  validates_associated :tag, on: :create
+  validates :name, presence: true, on: :create
   validate :validate_featured_tags_limit, on: :create
 
   def name=(str)
-    self.tag = Tag.find_or_initialize_by(name: str.delete('#').mb_chars.downcase.to_s)
+    self.tag = Tag.find_or_initialize_by(name: str.strip.delete('#').mb_chars.downcase.to_s)
   end
 
   def increment(timestamp)