Fix #5150: rating: metatag doesn't work on betabooru upload page.

This commit is contained in:
evazion
2022-04-30 20:22:26 -05:00
parent ccd0dde081
commit fdc1130aea
2 changed files with 9 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ class Post < ApplicationRecord
normalize :source, :normalize_source
before_validation :merge_old_changes
before_validation :normalize_tags
before_validation :apply_pre_metatags
before_validation :blank_out_nonexistent_parents
before_validation :remove_parent_loops
validates :md5, uniqueness: { message: ->(post, _data) { "Duplicate of post ##{Post.find_by_md5(post.md5).id}" }}, on: :create
@@ -23,7 +24,6 @@ class Post < ApplicationRecord
validates :source, length: { maximum: 1200 }
validate :post_is_not_its_own_parent
validate :uploader_is_not_limited, on: :create
before_save :apply_pre_metatags
before_save :parse_pixiv_id
before_save :added_tags_are_valid
before_save :removed_tags_are_valid

View File

@@ -745,6 +745,14 @@ class PostTest < ActiveSupport::TestCase
assert_equal("q", @post.rating)
end
end
context "when a post is created" do
should "set the rating" do
@post = create(:post, tag_string: "tagme rating:e", rating: nil)
assert_equal("e", @post.rating)
end
end
end
context "for a fav" do