uploads: fix 'rating:safe' not assigning the rating (#3929).

This commit is contained in:
evazion
2018-10-01 11:09:00 -05:00
parent 2ae7ec42df
commit 215591403e
2 changed files with 13 additions and 1 deletions

View File

@@ -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

View File

@@ -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