Skip to content

Default values don't work for grouped parameters #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions spec/grape/validations/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ class API < Grape::API
get '/numbers' do
{ random_number: params[:random], non_random_number: params[:non_random_number] }
end

params do
group :foo do
optional :bar, default: 'foo-bar'
end
end
get '/group' do
{ foo_bar: params[:foo][:bar] }
end
end
end
end
Expand Down Expand Up @@ -83,4 +92,11 @@ def app
before['non_random_number'].should == after['non_random_number']
before['random_number'].should_not == after['random_number']
end

it 'set default values for optional grouped params' do
get('/group')
last_response.status.should == 200
last_response.body.should == { foo_bar: 'foo-bar' }.to_json
end

end