Skip to content

Commit

Permalink
Merge 9f3fea8 into b79bd9c
Browse files Browse the repository at this point in the history
  • Loading branch information
ksss committed Mar 11, 2019
2 parents b79bd9c + 9f3fea8 commit 9416da1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

#### Features

* Your contribution here.
* [#1864](https://github.com/ruby-grape/grape/pull/1864): Adds `finally` on the API - [@myxoh](https://github.com/myxoh).

#### Fixes

* Your contribution here.
* [#1868](https://github.com/ruby-grape/grape/pull/1868): Fix NoMethodError with none hash params - [@ksss](https://github.com/ksss).

### 1.2.3 (2019/01/16)

Expand Down
1 change: 1 addition & 0 deletions lib/grape/validations/params_scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def meets_dependency?(params, request_params)

return true unless @dependent_on
return params.any? { |param| meets_dependency?(param, request_params) } if params.is_a?(Array)
return false unless params.respond_to?(:with_indifferent_access)
params = params.with_indifferent_access

@dependent_on.each do |dependency|
Expand Down
20 changes: 20 additions & 0 deletions spec/grape/validations/params_scope_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,26 @@ def initialize(value)
end

context 'when validations are dependent on a parameter within an array param' do
before do
subject.params do
requires :foos, type: Array do
optional :foo
given :foo do
requires :bar
end
end
end
subject.get('/test') { 'ok' }
end

it 'should pass none Hash params' do
get '/test', foos: ['']
expect(last_response.status).to eq(200)
expect(last_response.body).to eq('ok')
end
end

context 'when validations are dependent on a parameter within an array param within #declared(params).to_json' do
before do
subject.params do
requires :foos, type: Array do
Expand Down

0 comments on commit 9416da1

Please sign in to comment.