diff --git a/CHANGELOG.md b/CHANGELOG.md index ddd2fd18d..09deb1f9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ #### Fixes +* [#2586](https://github.com/ruby-grape/grape/pull/2586): Limit helpers DSL public scope - [@ericproulx](https://github.com/ericproulx). * [#2588](https://github.com/ruby-grape/grape/pull/2588): Fix defaut format regression on */* - [@ericproulx](https://github.com/ericproulx). * Your contribution here. diff --git a/lib/grape/dsl/helpers.rb b/lib/grape/dsl/helpers.rb index 4338ff1ac..e61c32a27 100644 --- a/lib/grape/dsl/helpers.rb +++ b/lib/grape/dsl/helpers.rb @@ -34,7 +34,7 @@ def helpers(*new_modules, &block) include_all_in_scope if !block && new_modules.empty? end - protected + private def include_new_modules(modules) return if modules.empty? diff --git a/spec/grape/dsl/helpers_spec.rb b/spec/grape/dsl/helpers_spec.rb index a1b07bd5c..b046e9222 100644 --- a/spec/grape/dsl/helpers_spec.rb +++ b/spec/grape/dsl/helpers_spec.rb @@ -113,5 +113,11 @@ def test expect { api_class }.not_to raise_exception end end + + context 'public scope' do + it 'returns helpers only' do + expect(Class.new { extend Grape::DSL::Helpers }.singleton_methods - Class.methods).to contain_exactly(:helpers) + end + end end end