From f627044ce1866ace962aeace13dc8d4d578699ce Mon Sep 17 00:00:00 2001 From: fsainz <167863+fsainz@users.noreply.github.com> Date: Tue, 19 Jan 2021 14:20:13 +0100 Subject: [PATCH 1/2] fixes configuration inside namespaced params scope --- lib/grape/validations/params_scope.rb | 2 +- spec/grape/api_remount_spec.rb | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/grape/validations/params_scope.rb b/lib/grape/validations/params_scope.rb index 792762b06a..a39383d5dd 100644 --- a/lib/grape/validations/params_scope.rb +++ b/lib/grape/validations/params_scope.rb @@ -39,7 +39,7 @@ def initialize(opts, &block) end def configuration - @api.configuration.evaluate + @api.configuration.respond_to?(:evaluate) ? @api.configuration.evaluate : @api.configuration end # @return [Boolean] whether or not this entire scope needs to be diff --git a/spec/grape/api_remount_spec.rb b/spec/grape/api_remount_spec.rb index 2f75017654..ff764293cd 100644 --- a/spec/grape/api_remount_spec.rb +++ b/spec/grape/api_remount_spec.rb @@ -340,19 +340,24 @@ def app context 'when the configuration is read within a namespace' do before do a_remounted_api.namespace 'api' do + params do + requires configuration[:required_param] + end get "/#{configuration[:path]}" do '10 votes' end end - root_api.mount a_remounted_api, with: { path: 'votes' } - root_api.mount a_remounted_api, with: { path: 'scores' } + root_api.mount a_remounted_api, with: { path: 'votes', required_param: 'param_key' } + root_api.mount a_remounted_api, with: { path: 'scores', required_param: 'param_key' } end it 'will use the dynamic configuration on all routes' do - get 'api/votes' + get 'api/votes', param_key: 'a' expect(last_response.body).to eql '10 votes' - get 'api/scores' + get 'api/scores', param_key: 'a' expect(last_response.body).to eql '10 votes' + get 'api/votes' + expect(last_response.status).to eq 400 end end From a55dee930a4b7a2979b4f01247c908130d8f70fc Mon Sep 17 00:00:00 2001 From: fsainz <167863+fsainz@users.noreply.github.com> Date: Mon, 25 Jan 2021 08:24:26 +0100 Subject: [PATCH 2/2] adds changlog line --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad0462bf93..ad32abbc99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ * [#2137](https://github.com/ruby-grape/grape/pull/2137): Fix typos - [@johnny-miyake](https://github.com/johnny-miyake). * [#2131](https://github.com/ruby-grape/grape/pull/2131): Fix Ruby 2.7 keyword deprecation warning in validators/coerce - [@K0H205](https://github.com/K0H205). * [#2132](https://github.com/ruby-grape/grape/pull/2132): Use #ruby2_keywords for correct delegation on Ruby <= 2.6, 2.7 and 3 - [@eregon](https://github.com/eregon). +* [#2152](https://github.com/ruby-grape/grape/pull/2152): Fix configuration method inside namespaced params - [@fsainz](https://github.com/fsainz). ### 1.5.1 (2020/11/15)