Skip to content

Commit

Permalink
backport: Fix DependencyResolver for 0.26.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentinchampenois committed Nov 28, 2023
1 parent 8cce634 commit 974f09a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Application < Rails::Application
end

config.after_initialize do
require "extends/lib/decidim/dependency_resolver_extends"
require "extends/controllers/decidim/devise/sessions_controller_extends"
end
end
Expand Down
29 changes: 29 additions & 0 deletions lib/extends/lib/decidim/dependency_resolver_extends.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# frozen_string_literal: true

# Backport from https://github.com/decidim/decidim/pull/12061/files
# Related to : https://github.com/decidim/decidim/issues/11636
module DependencyResolverExtends
# Finds a gem specification from the locked gems of the instance.
#
# Note that this does not resolve if the module is needed or not. This may
# also return the gem specification even when it is not listed in the
# Gemfile, e.g. when the Decidim gems are installed through git.
#
# @param name [String] The name of the gem to find.
# @return [Bundler::LazySpecification, nil] The specification for the gem
# or nil if the gem is not listed in the locked gems.
def spec(name)
sp = Bundler.definition.locked_gems.specs.find { |s| s.name == name }

# Fetching the gem through Gem.loaded_specs ensures we are not returning
# a lazy specification which does not respond to `#full_gem_path` which
# is needed for the resolver.
return Gem.loaded_specs[sp.name] if sp

nil
end
end

Decidim::DependencyResolver::Lookup.class_eval do
prepend(DependencyResolverExtends)
end

0 comments on commit 974f09a

Please sign in to comment.