From fdc1130aeaa51dc4970bd26f37ed4f8881210873 Mon Sep 17 00:00:00 2001 From: evazion Date: Sat, 30 Apr 2022 20:22:26 -0500 Subject: [PATCH] Fix #5150: rating: metatag doesn't work on betabooru upload page. --- app/models/post.rb | 2 +- test/unit/post_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/post.rb b/app/models/post.rb index a09abb6ad..0b87f62c3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 9a1203355..e50175dd0 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -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