-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Given does not use proper nesting in declared(params) #1219
Comments
Add requires :bar, type: Hash do
optional :a
optional :b
given :a do
requires :b
end
end subject.get('/nested') { declared(params).to_json }
get '/nested', bar: { a: true, b: 'yes' }
=> {"b":null,"bar":{"a":"true","b":"yes"}} The declared method returns only declared params? |
@stjhimy Ha thanks that seems to solve the issue. But the syntax is not really clear, why do I need the extra I thought (and from the documentation) that I should only need the |
I think that |
I still think this is a bug and not really a feature request. Following example right from the specs subject.params do
optional :a
given :a do
requires :b
end
end
subject.get('/test') { declared(params).to_json } Why does this work out of the box without the I think that If its implemented that Anyway quoting from the docs:
This implies for me the behaviour |
Ok I am with you wrt bug. Would love a fix. |
When using
given
block inside a nested requires block the validation works properly. But when trying to access these required params they are not nested in the requires block. Following spec (spec/grape/validations/params_scope_spec.rb) illustrate the problemThis fails with following message:
I tried different options (repeating the requires block in the given block) but nothing seems to work. I also cannot find the root of the problem but I guess it has to do with the following MR: #1047
The text was updated successfully, but these errors were encountered: