mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-11-29 10:24:20 +01:00
(bug) unsupported param[] syntax in OpenAPI
This commit is contained in:
parent
9ac2655256
commit
dcaa5ad28c
@ -7,6 +7,7 @@
|
|||||||
- OpenAPI users endpoint offer ability to filter by created_after
|
- 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: 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: unable to manage stocks on new products
|
||||||
|
- Fix a bug: unsupported param[] syntax in OpenAPI
|
||||||
- Updated react-modal to 3.16.1
|
- Updated react-modal to 3.16.1
|
||||||
- Updated tiptap editor and its dependencies to 2.0.0-beta.204
|
- Updated tiptap editor and its dependencies to 2.0.0-beta.204
|
||||||
- [TODO DEPLOY] `rails fablab:setup:build_accounting_lines`
|
- [TODO DEPLOY] `rails fablab:setup:build_accounting_lines`
|
||||||
|
@ -85,6 +85,8 @@ module ApplicationHelper
|
|||||||
|
|
||||||
# Return the given parameter as it, or as an array if it can be parsed as an array
|
# Return the given parameter as it, or as an array if it can be parsed as an array
|
||||||
def may_array(param)
|
def may_array(param)
|
||||||
|
return param if param.is_a?(Array)
|
||||||
|
|
||||||
return param unless param&.chars&.first == '[' && param&.chars&.last == ']'
|
return param unless param&.chars&.first == '[' && param&.chars&.last == ']'
|
||||||
|
|
||||||
param.gsub(/[\[\]]/i, '').split(',')
|
param.gsub(/[\[\]]/i, '').split(',')
|
||||||
|
@ -38,6 +38,16 @@ class OpenApi::UsersTest < ActionDispatch::IntegrationTest
|
|||||||
assert(users[:users].all? { |user| [3, 4, 5].include?(user[:id]) })
|
assert(users[:users].all? { |user| [3, 4, 5].include?(user[:id]) })
|
||||||
end
|
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
|
test 'list a user filtering by ID' do
|
||||||
get '/open_api/v1/users?user_id=2', headers: open_api_headers(@token)
|
get '/open_api/v1/users?user_id=2', headers: open_api_headers(@token)
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
Loading…
Reference in New Issue
Block a user