A platform for community discussion. Free, open, simple.
Support parsing array in #param_to_integer_list
Akshay Birajdar6b5e8be25a41
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex 74eab9c71f3..be5fd3b01f5 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 founddef param_to_integer_list(key, delimiter = ',')- if params[key]+ case params[key]+ when Stringparams[key].split(delimiter).map(&:to_i)+ when Array+ params[key].map(&:to_i)endenddiff --git a/spec/requests/list_controller_spec.rb b/spec/requests/list_controller_spec.rbindex c00c7c96097..5eb3d2362c7 100644--- a/spec/requests/list_controller_spec.rb+++ b/spec/requests/list_controller_spec.rb@@ -55,6 +55,12 @@ RSpec.describe ListController doget "/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|