From 7176948ce526f3543b8fc6555f0a0ea843af34f8 Mon Sep 17 00:00:00 2001 From: Madeline Collier Date: Thu, 8 Aug 2024 12:33:42 +0200 Subject: [PATCH 1/2] Fix failing solidus_admin thumbnail spec Failure: /spec/components/solidus_admin/ui/thumbnail/component_spec.rb:6 Error: /home/circleci/solidus/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb:53: numbered parameter is already used in /home/circleci/solidus/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb:52: outer block here Failure/Error: <% image = Spree::Image.new.tap { _1.define_singleton_method(:attachment) { attachment } } %> By replaing the second instance of numbered params, we can avoid this error with no behavioural or functional changes to the code. Interestingly though, it was only failing on 2 out of our 8 spec runs, and it did so consistently. --- .../ui/thumbnail/component_preview/overview.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb b/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb index caa4fb043ee..9d9db7f2628 100644 --- a/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb +++ b/admin/spec/components/previews/solidus_admin/ui/thumbnail/component_preview/overview.html.erb @@ -50,7 +50,7 @@
<% product = Spree::Product.new(name: "A good product") %> <% attachment = Object.new.tap { def _1.url(*) "https://placekitten.com/280/200"; end } %> - <% image = Spree::Image.new.tap { _1.define_singleton_method(:attachment) { attachment } } %> + <% image = Spree::Image.new.tap { |img| img.define_singleton_method(:attachment) { attachment } } %> <% [ Spree::UnitCancel.new, Spree::TaxRate.new, From 1664d10fa64b48d4be210e98d4a744bcd41a1f17 Mon Sep 17 00:00:00 2001 From: Madeline Collier Date: Wed, 7 Aug 2024 19:41:36 +0200 Subject: [PATCH 2/2] Lock solidus_core.gemspec to ransack '< 4.2' Solidus core's gemspec already required that ransack be '~> 4.0', but the latest version of ransack, v4.2.0, released July 10 2024, introduces a bug. The previous implementation was taking for granted that every predicate would respond to #value, which doesn't seem to be the case when the predicate is an instance of a Arel::SelectManager. This has already been flagged by @spaghetticode in his PR against ransack: https://github.com/activerecord-hackery/ransack/pull/1468 Since there has been little movement on this PR since January, we should lock to a version that works for us since currently many of our product specs are failing. (eg. spec/models/spree/product_spec.rb:659) We can remove this lock once the PR is merged and once the above test (and the others that are failing) are able to pass in ransack v4.2.0 or subsequent versions. --- core/solidus_core.gemspec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/solidus_core.gemspec b/core/solidus_core.gemspec index b6aff3cfc6c..43ec266f676 100644 --- a/core/solidus_core.gemspec +++ b/core/solidus_core.gemspec @@ -43,7 +43,9 @@ Gem::Specification.new do |s| s.add_dependency 'monetize', '~> 1.8' s.add_dependency 'kt-paperclip', ['>= 6.3', '< 8'] s.add_dependency 'psych', ['>= 4.0.1', '< 6.0'] - s.add_dependency 'ransack', '~> 4.0' + # @note ransack 4.2 contains a bug which has not yet been addressed. + # @see https://github.com/activerecord-hackery/ransack/pull/1468 + s.add_dependency 'ransack', ['~> 4.0', '< 4.2'] s.add_dependency 'sprockets-rails', '!= 3.5.0' s.add_dependency 'state_machines-activerecord', '~> 0.6' s.add_dependency 'omnes', '~> 0.2.2'