1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

(bug) unsupported param[] syntax in OpenAPI

This commit is contained in:
Sylvain 2022-12-07 12:43:36 +01:00
parent 9ac2655256
commit dcaa5ad28c
3 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,7 @@
- OpenAPI users endpoint offer ability to filter by created_after
- Fix a bug: providing an array of attributes to filter OpenApi data, results in error
- Fix a bug: unable to manage stocks on new products
- Fix a bug: unsupported param[] syntax in OpenAPI
- Updated react-modal to 3.16.1
- Updated tiptap editor and its dependencies to 2.0.0-beta.204
- [TODO DEPLOY] `rails fablab:setup:build_accounting_lines`

View File

@ -85,6 +85,8 @@ module ApplicationHelper
# Return the given parameter as it, or as an array if it can be parsed as an array
def may_array(param)
return param if param.is_a?(Array)
return param unless param&.chars&.first == '[' && param&.chars&.last == ']'
param.gsub(/[\[\]]/i, '').split(',')

View File

@ -38,6 +38,16 @@ class OpenApi::UsersTest < ActionDispatch::IntegrationTest
assert(users[:users].all? { |user| [3, 4, 5].include?(user[:id]) })
end
test 'list all users filtering by IDs other syntax' do
get '/open_api/v1/users?user_id[]=3&user_id[]=4&user_id[]=5', headers: open_api_headers(@token)
assert_response :success
assert_equal Mime[:json], response.content_type
users = json_response(response.body)
assert users[:users].count.positive?
assert(users[:users].all? { |user| [3, 4, 5].include?(user[:id]) })
end
test 'list a user filtering by ID' do
get '/open_api/v1/users?user_id=2', headers: open_api_headers(@token)
assert_response :success