mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 00:24:42 +08:00
Add fields to query params for ApiClient
This commit is contained in:
parent
88d96c0938
commit
c691ad80b5
3 changed files with 6 additions and 4 deletions
|
@ -40,12 +40,12 @@ module ProtocolImporters
|
|||
end
|
||||
|
||||
# try if order_field is ok
|
||||
if CONSTANTS[:available_order_fields]&.exclude? @query_params[:order_field].to_sym
|
||||
if @query_params[:order_field] && CONSTANTS[:available_order_fields].exclude?(@query_params[:order_field]&.to_sym)
|
||||
@errors[:invalid_params][:order_field] = 'Order field is not ok'
|
||||
end
|
||||
|
||||
# try if order dir is ok
|
||||
if CONSTANTS[:available_order_dirs]&.exclude? @query_params[:order_dir].to_sym
|
||||
if @query_params[:order_field] && CONSTANTS[:available_order_dirs].exclude?(@query_params[:order_dir]&.to_sym)
|
||||
@errors[:invalid_params][:order_dir] = 'Order dir is not ok'
|
||||
end
|
||||
|
||||
|
|
|
@ -213,7 +213,8 @@ class Constants
|
|||
order_field: :activity,
|
||||
order_dir: :desc,
|
||||
page_size: 10,
|
||||
page_id: 1
|
||||
page_id: 1,
|
||||
fields: 'id,title,authors,created_on,uri,stats'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -44,7 +44,8 @@ describe ProtocolImporters::ProtocolsIO::V3::ApiClient do
|
|||
order_dir: :asc,
|
||||
order_field: :date,
|
||||
page_id: 2,
|
||||
page_size: 15
|
||||
page_size: 15,
|
||||
fields: 'somefields'
|
||||
}
|
||||
stub_request(:get, URL).with(query: query)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue