Support parsing array in #param_to_integer_list
Co-authored-by: Akshay Birajdar <akshay.birajdar@coupa.com>
This commit is contained in:
parent
cfabdb72bc
commit
6b5e8be25a
|
@ -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
|
||||
|
||||
|
|
|
@ -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|
|
||||
|
|
Loading…
Reference in New Issue