FIX: Generate Topic Thumbnails nil to Array error

If any value, including nil, is passed in as an argument the default
won't be set, so we need to handle when a non-Array value is passed in
to the `generate_thumbnails!` method.
This commit is contained in:
Blake Erickson 2020-07-06 15:30:57 -06:00
parent 90524906ee
commit 2e13ed061d
2 changed files with 2 additions and 1 deletions

View File

@ -95,6 +95,7 @@ class Topic < ActiveRecord::Base
return nil unless SiteSetting.create_thumbnails
return nil unless original = image_upload
return nil unless original.width && original.height
extra_sizes = [] unless extra_sizes.kind_of?(Array)
(Topic.thumbnail_sizes + extra_sizes).each do |dim|
TopicThumbnail.find_or_create_for!(original, max_width: dim[0], max_height: dim[1])

View File

@ -7,7 +7,7 @@ describe "TopicThumbnail" do
before do
SiteSetting.create_thumbnails = true
topic.generate_thumbnails!
topic.generate_thumbnails!(extra_sizes: nil)
TopicThumbnail.ensure_consistency!
topic.reload