Support parsing array in #param_to_integer_list

Support parsing array in #param_to_integer_list

Co-authored-by: Akshay Birajdar akshay.birajdar@coupa.com

diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 74eab9c..be5fd3b 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -928,8 +928,11 @@ class ApplicationController < ActionController::Base
   # returns an array of integers given a param key
   # returns nil if key is not found
   def param_to_integer_list(key, delimiter = ',')
-    if params[key]
+    case params[key]
+    when String
       params[key].split(delimiter).map(&:to_i)
+    when Array
+      params[key].map(&:to_i)
     end
   end
 
diff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rb
index c00c7c9..5eb3d23 100644
--- a/spec/requests/list_controller_spec.rb
+++ b/spec/requests/list_controller_spec.rb
@@ -55,6 +55,12 @@ RSpec.describe ListController do
 
       get "/latest?search="
       expect(response.status).to eq(200)
+
+      get "/latest.json?topic_ids%5B%5D=14583&topic_ids%5B%5D=14584"
+      expect(response.status).to eq(200)
+
+      get "/latest.json?topic_ids=14583%2C14584"
+      expect(response.status).to eq(200)
     end
 
     (Discourse.anonymous_filters - [:categories]).each do |filter|

GitHub sha: 6b5e8be25a41a759a4d53c8796a9e0b878923f8e

This commit appears in #14808 which was approved by eviltrout. It was merged by eviltrout.