File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,11 @@ def get_stat_parameter_request_info
8989 parameters . delete ( 'controller' ) ;
9090 parameters . delete ( 'action' ) ;
9191
92+ # NOTICE: Remove the field information from group_by_field => collection:id
93+ if parameters [ 'group_by_field' ]
94+ parameters [ 'group_by_field' ] = parameters [ 'group_by_field' ] . split ( ':' ) . first
95+ end
96+
9297 return parameters ;
9398 end
9499
Original file line number Diff line number Diff line change @@ -177,13 +177,12 @@ def stat_with_parameters_allowed?
177177 return false unless pool_permissions
178178
179179 # NOTICE: equivalent to Object.values in js & removes nil values
180- array_query_request_info = @query_request_info . values . filter_map { |x | x unless x . nil? }
180+ array_permission_infos = @query_request_info . values . filter_map { |x | x unless x . nil? }
181181
182- # NOTICE: pool_permissions contains the @query_request_info
183- # we use the intersection between statPermission and @query_request_info
182+ # NOTICE: Is there any pool_permissions containing the array_permission_infos
184183 return pool_permissions . any? {
185184 |statPermission |
186- ( array_query_request_info & statPermission . values ) == array_query_request_info ;
185+ ( array_permission_infos . all? { | info | statPermission . values . include? ( info ) } ) ;
187186 }
188187 end
189188
Original file line number Diff line number Diff line change 7272 expect ( response . status ) . to eq ( 404 )
7373 end
7474
75- # it 'should respond 403 Forbidden' do
76- # allow_any_instance_of(ForestLiana::PermissionsChecker).to receive(:is_authorized?) { false }
75+ it 'should respond 403 Forbidden' do
76+ allow_any_instance_of ( ForestLiana ::PermissionsChecker ) . to receive ( :is_authorized? ) { false }
77+ # NOTICE: bypass : find_resource error
78+ allow_any_instance_of ( ForestLiana ::StatsController ) . to receive ( :find_resource ) { true }
7779
78- # post '/forest/stats/Products', params: JSON.dump(params), headers: headers
79- # expect(response.status).to eq(403)
80- # end
80+ post '/forest/stats/Products' , params : JSON . dump ( params ) , headers : headers
81+ expect ( response . status ) . to eq ( 403 )
82+ end
8183 end
8284
8385 describe 'POST /stats' do
You can’t perform that action at this time.
0 commit comments