FIX: Generate Topic Thumbnails nil to Array error

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.

diff --git a/app/models/topic.rb b/app/models/topic.rb
index 54c7ffc..7ee0ea4 100644
--- a/app/models/topic.rb
+++ b/app/models/topic.rb
@@ -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])
diff --git a/spec/models/topic_thumbnail_spec.rb b/spec/models/topic_thumbnail_spec.rb
index b9e1df7..84c8298 100644
--- a/spec/models/topic_thumbnail_spec.rb
+++ b/spec/models/topic_thumbnail_spec.rb
@@ -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

GitHub sha: 2e13ed06