From 8de048ed5681a69730f8b5681fb5dd1fb80ddd5e Mon Sep 17 00:00:00 2001 From: Eric Proulx Date: Mon, 30 Oct 2023 19:01:42 +0100 Subject: [PATCH] Add missing requires (#2365) * Add require 'active_support/core_ext/enumerable' * Add changelog * Replace first, second by [0], [1] require missing core_ext/object/deep_dup && core_ext/string/exclude * grape_entity require false * Update CHANGELOG.md --- CHANGELOG.md | 1 + Gemfile | 2 +- gemfiles/multi_json.gemfile | 2 +- gemfiles/multi_xml.gemfile | 2 +- gemfiles/rack_1_0.gemfile | 2 +- gemfiles/rack_2_0.gemfile | 2 +- gemfiles/rack_3_0.gemfile | 2 +- gemfiles/rack_edge.gemfile | 2 +- gemfiles/rails_5_2.gemfile | 2 +- gemfiles/rails_6_0.gemfile | 2 +- gemfiles/rails_6_1.gemfile | 2 +- gemfiles/rails_7_0.gemfile | 2 +- gemfiles/rails_7_1.gemfile | 2 +- gemfiles/rails_edge.gemfile | 2 +- lib/grape.rb | 3 +++ spec/grape/endpoint_spec.rb | 4 ++-- 16 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aabf664f24..6618fadeb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ #### Fixes +* [#2364](https://github.com/ruby-grape/grape/pull/2364): Add missing requires - [@ericproulx](https://github.com/ericproulx). * Your contribution here. ### 1.8.0 (2023/08/30) diff --git a/Gemfile b/Gemfile index 7bce1e5989..ddd2a49f25 100644 --- a/Gemfile +++ b/Gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/multi_json.gemfile b/gemfiles/multi_json.gemfile index 84d5e16389..b1c6e91e0c 100644 --- a/gemfiles/multi_json.gemfile +++ b/gemfiles/multi_json.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/multi_xml.gemfile b/gemfiles/multi_xml.gemfile index eebdc1b088..02fdd91cf5 100644 --- a/gemfiles/multi_xml.gemfile +++ b/gemfiles/multi_xml.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rack_1_0.gemfile b/gemfiles/rack_1_0.gemfile index 862236c802..7aa8c64518 100644 --- a/gemfiles/rack_1_0.gemfile +++ b/gemfiles/rack_1_0.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rack_2_0.gemfile b/gemfiles/rack_2_0.gemfile index e75b1699c9..69d7ec28f9 100644 --- a/gemfiles/rack_2_0.gemfile +++ b/gemfiles/rack_2_0.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rack_3_0.gemfile b/gemfiles/rack_3_0.gemfile index 2da2241a91..24ad9ac310 100644 --- a/gemfiles/rack_3_0.gemfile +++ b/gemfiles/rack_3_0.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rack_edge.gemfile b/gemfiles/rack_edge.gemfile index 5d9c93ae02..0e1133d74c 100644 --- a/gemfiles/rack_edge.gemfile +++ b/gemfiles/rack_edge.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rails_5_2.gemfile b/gemfiles/rails_5_2.gemfile index 3ff9979749..f5e3f2a55c 100644 --- a/gemfiles/rails_5_2.gemfile +++ b/gemfiles/rails_5_2.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rails_6_0.gemfile b/gemfiles/rails_6_0.gemfile index e0f12b62f6..996b1210b6 100644 --- a/gemfiles/rails_6_0.gemfile +++ b/gemfiles/rails_6_0.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rails_6_1.gemfile b/gemfiles/rails_6_1.gemfile index 10a8c9eefd..3b8c16a3eb 100644 --- a/gemfiles/rails_6_1.gemfile +++ b/gemfiles/rails_6_1.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rails_7_0.gemfile b/gemfiles/rails_7_0.gemfile index 97b71f0e78..914f94c8f9 100644 --- a/gemfiles/rails_7_0.gemfile +++ b/gemfiles/rails_7_0.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rails_7_1.gemfile b/gemfiles/rails_7_1.gemfile index 01fbd7900d..4fc39fe8f5 100644 --- a/gemfiles/rails_7_1.gemfile +++ b/gemfiles/rails_7_1.gemfile @@ -27,7 +27,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/gemfiles/rails_edge.gemfile b/gemfiles/rails_edge.gemfile index cc01d9f976..cb144118e7 100644 --- a/gemfiles/rails_edge.gemfile +++ b/gemfiles/rails_edge.gemfile @@ -26,7 +26,7 @@ end group :test do gem 'cookiejar' - gem 'grape-entity', '~> 0.6' + gem 'grape-entity', '~> 0.6', require: false gem 'mime-types' gem 'rack-jsonp', require: 'rack/jsonp' gem 'rack-test', '< 2.1' diff --git a/lib/grape.rb b/lib/grape.rb index 9eeecbde5a..6d4d90e1cc 100644 --- a/lib/grape.rb +++ b/lib/grape.rb @@ -16,6 +16,7 @@ require 'active_support/core_ext/array/conversions' require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/array/wrap' +require 'active_support/core_ext/enumerable' require 'active_support/core_ext/hash/conversions' require 'active_support/core_ext/hash/deep_merge' require 'active_support/core_ext/hash/except' @@ -24,7 +25,9 @@ require 'active_support/core_ext/hash/reverse_merge' require 'active_support/core_ext/hash/slice' require 'active_support/core_ext/object/blank' +require 'active_support/core_ext/object/deep_dup' require 'active_support/core_ext/object/duplicable' +require 'active_support/core_ext/string/exclude' require 'active_support/dependencies/autoload' require 'active_support/deprecation' require 'active_support/inflector' diff --git a/spec/grape/endpoint_spec.rb b/spec/grape/endpoint_spec.rb index 400b45c404..8cdcc1cffe 100644 --- a/spec/grape/endpoint_spec.rb +++ b/spec/grape/endpoint_spec.rb @@ -201,8 +201,8 @@ def app get('/username', {}, 'HTTP_COOKIE' => 'username=user; sandbox=false') expect(last_response.body).to eq('user_test') cookies = Array(last_response.headers['Set-Cookie']).flat_map { |h| h.split("\n") } - expect(cookies.first).to match(/username=user_test/) - expect(cookies.second).to match(/sandbox=true/) + expect(cookies[0]).to match(/username=user_test/) + expect(cookies[1]).to match(/sandbox=true/) end it 'deletes cookie' do