File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 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)
9999 end
100100
101101 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 )
103103 end
104104
105- def declared_param_is_hash ?( params_nested_path )
105+ def declared_param_is_empty_hash ?( params_nested_path )
106106 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
108110 end
109111
110112 def route_options_params
Original file line number Diff line number Diff line change @@ -393,7 +393,11 @@ def app
393393
394394 get '/declared?first=present&nested[fourth]=1'
395395 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 ] )
397401 end
398402
399403 it 'builds nested params when given array' do
@@ -424,7 +428,7 @@ def app
424428
425429 get '/declared?first=present'
426430 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 )
428432 end
429433
430434 it 'to be an array when include_missing is true' do
You can’t perform that action at this time.
0 commit comments