File tree 2 files changed +11
-5
lines changed
2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -99,12 +99,14 @@ def declared_param_is_array?(params_nested_path)
99
99
end
100
100
101
101
def should_be_empty_hash? ( passed_children_params , params_nested_path )
102
- passed_children_params . empty? && declared_param_is_hash ?( params_nested_path )
102
+ passed_children_params . empty? && declared_param_is_empty_hash ?( params_nested_path )
103
103
end
104
104
105
- def declared_param_is_hash ?( params_nested_path )
105
+ def declared_param_is_empty_hash ?( params_nested_path )
106
106
key = route_options_params_key ( params_nested_path )
107
- route_options_params [ key ] && route_options_params [ key ] [ :type ] == 'Hash'
107
+ has_children = route_options_params . keys . any? { |k | k != key && k . start_with? ( key ) }
108
+
109
+ route_options_params [ key ] && route_options_params [ key ] [ :type ] == 'Hash' && !has_children
108
110
end
109
111
110
112
def route_options_params
Original file line number Diff line number Diff line change @@ -393,7 +393,11 @@ def app
393
393
394
394
get '/declared?first=present&nested[fourth]=1'
395
395
expect ( last_response . status ) . to eq ( 200 )
396
- expect ( JSON . parse ( last_response . body ) [ 'nested' ] . keys . size ) . to eq 4
396
+
397
+ body = JSON . parse ( last_response . body )
398
+ expect ( body [ 'nested' ] . keys ) . to eq ( %w[ fourth fifth nested_two nested_arr ] )
399
+ expect ( body [ 'nested' ] [ 'nested_two' ] . keys ) . to eq ( %w[ sixth nested_three ] )
400
+ expect ( body [ 'nested' ] [ 'nested_two' ] [ 'nested_three' ] . keys ) . to eq ( %w[ seventh ] )
397
401
end
398
402
399
403
it 'builds nested params when given array' do
@@ -424,7 +428,7 @@ def app
424
428
425
429
get '/declared?first=present'
426
430
expect ( last_response . status ) . to eq ( 200 )
427
- expect ( JSON . parse ( last_response . body ) [ 'nested' ] ) . to eq ( { } )
431
+ expect ( JSON . parse ( last_response . body ) [ 'nested' ] ) . to be_a ( Hash )
428
432
end
429
433
430
434
it 'to be an array when include_missing is true' do
You can’t perform that action at this time.
0 commit comments