FIX: remove nil items before sorting the sha1 string array. (#18571)

Previously, when the array had both nil and string values it returned the error "comparison of NilClass with String failed". Now I added the `.compact` method to prevent this issue as per @martin-brennan's suggestion https://github.com/discourse/discourse/pull/18431#discussion_r984204788
This commit is contained in:
Vinoth Kannan 2022-10-13 02:43:56 +05:30 committed by GitHub
parent 0fe111e492
commit 7f167de10b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -225,7 +225,7 @@ class Stylesheet::Manager::Builder
sha1s << upload_field.upload&.sha1
end
Digest::SHA1.hexdigest(sha1s.sort!.join("\n"))
Digest::SHA1.hexdigest(sha1s.compact.sort!.join("\n"))
end
def default_digest

View File

@ -374,6 +374,16 @@ RSpec.describe Stylesheet::Manager do
type_id: ThemeField.types[:theme_upload_var]
)
upload2 = UploadCreator.new(image2, "icon.png").create_for(-1)
field = ThemeField.create!(
theme_id: theme.id,
target_id: Theme.targets[:common],
name: "icon",
value: "",
upload_id: upload2.id,
type_id: ThemeField.types[:theme_upload_var]
)
manager = manager(theme.id)
builder = Stylesheet::Manager::Builder.new(