diff --git a/app/models/upload.rb b/app/models/upload.rb index 66588cedf..320e9c197 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -245,7 +245,7 @@ class Upload < ApplicationRecord def assign_rating_from_tags if rating = Tag.has_metatag?(tag_string, :rating) - self.rating = rating.downcase + self.rating = rating.downcase.first end end diff --git a/test/models/upload_service_test.rb b/test/models/upload_service_test.rb index 8b8e82410..7488952e8 100644 --- a/test/models/upload_service_test.rb +++ b/test/models/upload_service_test.rb @@ -1070,6 +1070,18 @@ class UploadServiceTest < ActiveSupport::TestCase service.start! end end + + should "assign the rating from tags" do + service = subject.new(source: @source, tag_string: "rating:safe blah") + upload = service.start! + + assert_equal(true, upload.valid?) + assert_equal("s", upload.rating) + assert_equal("rating:safe blah ", upload.tag_string) + + assert_equal("s", upload.post.rating) + assert_equal("blah", upload.post.tag_string) + end end end