Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

upgrade state machines and remove hack (#12855)

Abdelkader Boudih8c5408fdd8d8
diff --git a/core/config/initializers/state_machine.rb b/core/config/initializers/state_machine.rb
deleted file mode 100644
index c0f7e3fe30..0000000000
--- a/core/config/initializers/state_machine.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# frozen_string_literal: true
-
-module MachineDecorator
- protected
-
- # Determines whether there's already a helper method defined within the
- # given scope. This is true only if one of the owner's ancestors defines
- # the method and is further along in the ancestor chain than this
- # machine's helper module.
- def owner_class_ancestor_has_method?(scope, method)
- return false unless owner_class_has_method?(scope, method)
-
- superclasses = owner_class.ancestors.select { |ancestor| ancestor.is_a?(Class) }[1..-1]
-
- if scope == :class
- current = owner_class.singleton_class
- superclass = superclasses.first
- else
- current = owner_class
- superclass = owner_class.superclass
- end
-
- # Generate the list of modules that *only* occur in the owner class, but
- # were included *prior* to the helper modules, in addition to the
- # superclasses
- ancestors = current.ancestors - superclass.ancestors + superclasses
- ancestors = ancestors[ancestors.index(@helper_modules[scope])..-1].reverse
-
- # Search for for the first ancestor that defined this method
- ancestors.detect do |ancestor|
- ancestor = ancestor.singleton_class if scope == :class && ancestor.is_a?(Class)
- ancestor.method_defined?(method) || ancestor.private_method_defined?(method)
- end
- end
-end
-
-::StateMachines::Machine.prepend MachineDecorator
diff --git a/core/spree_core.gemspec b/core/spree_core.gemspec
index e6cb7f4c77..1209f8c801 100644
--- a/core/spree_core.gemspec
+++ b/core/spree_core.gemspec
@@ -49,8 +49,8 @@ Gem::Specification.new do |s|
s.add_dependency 'ransack', '>= 4.1'
s.add_dependency 'rexml'
s.add_dependency 'ruby-oembed', '~> 0.18'
- s.add_dependency 'state_machines-activerecord', '~> 0.6'
- s.add_dependency 'state_machines-activemodel', '~> 0.7'
+ s.add_dependency 'state_machines-activerecord', '~> 0.10'
+ s.add_dependency 'state_machines-activemodel', '~> 0.10'
s.add_dependency 'stringex'
s.add_dependency 'tracking_number'
s.add_dependency 'validates_zipcode'