Skip to content

Commit

Permalink
Merge 69b65fe into 6d2e332
Browse files Browse the repository at this point in the history
  • Loading branch information
dnesteryuk committed Jan 15, 2020
2 parents 6d2e332 + 69b65fe commit 44b948b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@

#### Fixes

* [#1976](https://github.com/ruby-grape/grape/pull/1976): Be sure classes/modules listed for autoload really exist - [@dnesteryuk](https://github.com/dnesteryuk).
* [#1971](https://github.com/ruby-grape/grape/pull/1971): Fix BigDecimal coercion - [@FlickStuart](https://github.com/FlickStuart).
* [#1968](https://github.com/ruby-grape/grape/pull/1968): Fix args forwarding in Grape::Middleware::Stack#merge_with for ruby 2.7.0 - [@dm1try](https://github.com/dm1try).

Expand Down
1 change: 0 additions & 1 deletion lib/grape.rb
Expand Up @@ -84,7 +84,6 @@ module Extensions
eager_autoload do
autoload :DeepMergeableHash
autoload :DeepSymbolizeHash
autoload :DeepHashWithIndifferentAccess
autoload :Hash
end
module ActiveSupport
Expand Down
20 changes: 20 additions & 0 deletions spec/spec_helper.rb
Expand Up @@ -10,6 +10,26 @@
require 'bundler'
Bundler.require :default, :test

# Grape uses autoload https://api.rubyonrails.org/classes/ActiveSupport/Autoload.html.
# When a class/module get added to the list, ActiveSupport doesn't check whether it really exists.
# This method loads all classes/modules defined via autoload to be sure only existing
# classes/modules were listed.
def force_autoload(scope)
# get modules
scope.constants.each do |const_name|
const = scope.const_get(const_name)

next unless const.respond_to?(:eager_load!)

const.eager_load!

# check its modules, they might need to be loaded as well.
force_autoload(const)
end
end

force_autoload Grape

Dir["#{File.dirname(__FILE__)}/support/*.rb"].each do |file|
require file
end
Expand Down

0 comments on commit 44b948b

Please sign in to comment.