From 20ea20d4e8e49ba74ff8231107b73ba6d397d43e Mon Sep 17 00:00:00 2001 From: Mehmet Emin INAC <minac@gitlab.com> Date: Wed, 15 Sep 2021 14:56:37 +0200 Subject: [PATCH] Upgrade grape-entity gem Upgrading the gem from `0.9.0` to `0.10.0` which contains just one change to address our patch. --- Gemfile | 2 +- Gemfile.lock | 4 +-- .../grape_entity_patch.rb | 27 ------------------- spec/config/grape_entity_patch_spec.rb | 21 --------------- 4 files changed, 3 insertions(+), 51 deletions(-) delete mode 100644 config/initializers_before_autoloader/grape_entity_patch.rb delete mode 100644 spec/config/grape_entity_patch_spec.rb diff --git a/Gemfile b/Gemfile index c71ac209ecf20..6fde72ec0634e 100644 --- a/Gemfile +++ b/Gemfile @@ -92,7 +92,7 @@ gem 'net-ldap', '~> 0.16.3' # API gem 'grape', '~> 1.5.2' -gem 'grape-entity', '~> 0.9.0' +gem 'grape-entity', '~> 0.10.0' gem 'rack-cors', '~> 1.0.6', require: 'rack/cors' # GraphQL API diff --git a/Gemfile.lock b/Gemfile.lock index 87f78455ee0f4..63b319f5f1f83 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -543,7 +543,7 @@ GEM mustermann-grape (~> 1.0.0) rack (>= 1.3.0) rack-accept - grape-entity (0.9.0) + grape-entity (0.10.0) activesupport (>= 3.0.0) multi_json (>= 1.3.2) grape-path-helpers (1.7.0) @@ -1485,7 +1485,7 @@ DEPENDENCIES google-protobuf (~> 3.17.1) gpgme (~> 2.0.19) grape (~> 1.5.2) - grape-entity (~> 0.9.0) + grape-entity (~> 0.10.0) grape-path-helpers (~> 1.7.0) grape_logging (~> 1.7) graphiql-rails (~> 1.4.10) diff --git a/config/initializers_before_autoloader/grape_entity_patch.rb b/config/initializers_before_autoloader/grape_entity_patch.rb deleted file mode 100644 index 2db5876e75f27..0000000000000 --- a/config/initializers_before_autoloader/grape_entity_patch.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# This can be removed after the problem gets fixed on upstream. -# You can follow https://github.com/ruby-grape/grape-entity/pull/355 to see the progress. -# -# For more information about the issue; -# https://github.com/ruby/did_you_mean/issues/158#issuecomment-906056018 - -require 'grape-entity' - -module Grape - class Entity - # Upstream version: https://github.com/ruby-grape/grape-entity/blob/675d3c0e20dfc1d6cf6f5ba5b46741bd404c8be7/lib/grape_entity/entity.rb#L520 - def exec_with_object(options, &block) - if block.parameters.count == 1 - instance_exec(object, &block) - else - instance_exec(object, options, &block) - end - rescue StandardError => e - # it handles: https://github.com/ruby/ruby/blob/v3_0_0_preview1/NEWS.md#language-changes point 3, Proc - raise Grape::Entity::Deprecated.new e.message, 'in ruby 3.0' if e.is_a?(ArgumentError) - - raise e - end - end -end diff --git a/spec/config/grape_entity_patch_spec.rb b/spec/config/grape_entity_patch_spec.rb deleted file mode 100644 index 7334f270ca1fe..0000000000000 --- a/spec/config/grape_entity_patch_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'Grape::Entity patch' do - let(:entity_class) { Class.new(Grape::Entity) } - - describe 'NameError in block exposure with argument' do - subject(:represent) { entity_class.represent({}, serializable: true) } - - before do - entity_class.expose :raise_no_method_error do |_| - foo - end - end - - it 'propagates the error to the caller' do - expect { represent }.to raise_error(NameError) - end - end -end -- GitLab