From 32ee9fc563982483745d256eebbd67a3234c2f32 Mon Sep 17 00:00:00 2001 From: Elias Date: Tue, 30 Jun 2026 14:07:45 +0300 Subject: [PATCH] fix(mpesa): insert Rack::Attack without the unsupported include? guard The rack_attack initializer guarded middleware insertion with app.middleware.include?(Rack::Attack), but Rails::Configuration::MiddlewareStackProxy does not implement include? on Rails 8.1. Booting in production therefore raised NoMethodError and broke asset precompilation in the deploy image. The guard also protected against a double insertion the host never performs. Insert Rack::Attack unconditionally, matching the standard Spree engine idiom. Bump the gemspec version to 1.0.1. --- lib/spree_mpesa/engine.rb | 2 +- spree_mpesa.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/spree_mpesa/engine.rb b/lib/spree_mpesa/engine.rb index dee84db..af70b73 100644 --- a/lib/spree_mpesa/engine.rb +++ b/lib/spree_mpesa/engine.rb @@ -18,7 +18,7 @@ class Engine < ::Rails::Engine begin require 'rack/attack' - app.middleware.use Rack::Attack unless app.middleware.include?(Rack::Attack) + app.middleware.use Rack::Attack rescue LoadError => e Rails.logger&.warn("spree_mpesa: rack-attack unavailable, callback throttling disabled (#{e.message})") end diff --git a/spree_mpesa.gemspec b/spree_mpesa.gemspec index aa9b9bd..17bd36a 100644 --- a/spree_mpesa.gemspec +++ b/spree_mpesa.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = 'spree_mpesa' - s.version = '0.1.0' + s.version = '1.0.1' s.summary = 'Direct M-Pesa (Safaricom Daraja) payment method for Spree Commerce' s.description = 'Spree extension that adds a direct M-Pesa paybill payment method ' \ 'using the Safaricom Daraja STK Push API, with no third-party aggregator.'