From 420deca43747625bc20db7da2a6dfbab4c93cf44 Mon Sep 17 00:00:00 2001 From: Carlos Chitty Date: Wed, 26 Mar 2025 12:33:05 -0400 Subject: [PATCH 1/5] Bump rails from 7.0.8 to 7.1.5.1 --- Gemfile.lock | 149 +++++++++++++++++++++++++++++---------------------- 1 file changed, 85 insertions(+), 64 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6c1600ba7d..8877750db8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -49,53 +49,57 @@ GEM remote: https://rubygems.org/ specs: Ascii85 (1.1.0) - actioncable (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) + actioncable (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + zeitwerk (~> 2.6) + actionmailbox (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8) - actionpack (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activesupport (= 7.0.8) + actionmailer (7.1.5.1) + actionpack (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activesupport (= 7.1.5.1) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.8) - actionview (= 7.0.8) - activesupport (= 7.0.8) - rack (~> 2.0, >= 2.2.4) + rails-dom-testing (~> 2.2) + actionpack (7.1.5.1) + actionview (= 7.1.5.1) + activesupport (= 7.1.5.1) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) actionpack-action_caching (1.2.2) actionpack (>= 4.0.0) - actiontext (7.0.8) - actionpack (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + actiontext (7.1.5.1) + actionpack (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8) - activesupport (= 7.0.8) + actionview (7.1.5.1) + activesupport (= 7.1.5.1) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) active_model_serializers (0.8.4) activemodel (>= 3.0) active_storage_validations (1.1.4) @@ -103,8 +107,8 @@ GEM activemodel (>= 5.2.0) activestorage (>= 5.2.0) activesupport (>= 5.2.0) - activejob (7.0.8) - activesupport (= 7.0.8) + activejob (7.1.5.1) + activesupport (= 7.1.5.1) globalid (>= 0.3.6) activemerchant (1.133.0) activesupport (>= 4.2) @@ -112,11 +116,12 @@ GEM i18n (>= 0.6.9) nokogiri (~> 1.4) rexml (~> 3.2.5) - activemodel (7.0.8) - activesupport (= 7.0.8) - activerecord (7.0.8) - activemodel (= 7.0.8) - activesupport (= 7.0.8) + activemodel (7.1.5.1) + activesupport (= 7.1.5.1) + activerecord (7.1.5.1) + activemodel (= 7.1.5.1) + activesupport (= 7.1.5.1) + timeout (>= 0.4.0) activerecord-import (1.6.0) activerecord (>= 4.2) activerecord-postgresql-adapter (0.0.1) @@ -128,17 +133,24 @@ GEM multi_json (~> 1.11, >= 1.11.2) rack (>= 2.0.8, < 4) railties (>= 6.1) - activestorage (7.0.8) - actionpack (= 7.0.8) - activejob (= 7.0.8) - activerecord (= 7.0.8) - activesupport (= 7.0.8) + activestorage (7.1.5.1) + actionpack (= 7.1.5.1) + activejob (= 7.1.5.1) + activerecord (= 7.1.5.1) + activesupport (= 7.1.5.1) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.8) + activesupport (7.1.5.1) + base64 + benchmark (>= 0.3) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) + logger (>= 1.4.2) minitest (>= 5.1) + mutex_m + securerandom (>= 0.3) tzinfo (~> 2.0) acts-as-taggable-on (10.0.0) activerecord (>= 6.1, < 7.2) @@ -180,6 +192,7 @@ GEM base64 (0.2.0) bcp47_spec (0.2.1) bcrypt (3.1.20) + benchmark (0.4.1) bigdecimal (3.2.2) bindata (2.5.0) bindex (0.8.1) @@ -270,6 +283,7 @@ GEM digest (3.1.1) docile (1.4.0) dotenv (3.1.2) + drb (2.2.3) em-http-request (1.1.7) addressable (>= 2.3.4) cookiejar (!= 0.3.1) @@ -435,6 +449,7 @@ GEM listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) + logger (1.7.0) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) @@ -463,6 +478,7 @@ GEM msgpack (1.7.2) multi_json (1.15.0) multi_xml (0.6.0) + mutex_m (0.3.0) net-http (0.4.1) uri net-imap (0.4.10) @@ -578,20 +594,23 @@ GEM rack-test (2.1.0) rack (>= 1.3) rack-timeout (0.7.0) - rails (7.0.8) - actioncable (= 7.0.8) - actionmailbox (= 7.0.8) - actionmailer (= 7.0.8) - actionpack (= 7.0.8) - actiontext (= 7.0.8) - actionview (= 7.0.8) - activejob (= 7.0.8) - activemodel (= 7.0.8) - activerecord (= 7.0.8) - activestorage (= 7.0.8) - activesupport (= 7.0.8) + rackup (1.0.1) + rack (< 3) + webrick + rails (7.1.5.1) + actioncable (= 7.1.5.1) + actionmailbox (= 7.1.5.1) + actionmailer (= 7.1.5.1) + actionpack (= 7.1.5.1) + actiontext (= 7.1.5.1) + actionview (= 7.1.5.1) + activejob (= 7.1.5.1) + activemodel (= 7.1.5.1) + activerecord (= 7.1.5.1) + activestorage (= 7.1.5.1) + activesupport (= 7.1.5.1) bundler (>= 1.15.0) - railties (= 7.0.8) + railties (= 7.1.5.1) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -612,13 +631,14 @@ GEM i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) rails_safe_tasks (1.0.0) - railties (7.0.8) - actionpack (= 7.0.8) - activesupport (= 7.0.8) - method_source + railties (7.1.5.1) + actionpack (= 7.1.5.1) + activesupport (= 7.1.5.1) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.2.1) ransack (4.1.1) @@ -752,6 +772,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) sd_notify (0.1.1) + securerandom (0.4.1) semantic_range (3.0.0) shoulda-matchers (6.2.0) activesupport (>= 5.2.0) From 3cb6a2617bc6a5e19ebe49d15d51482bb4e68e24 Mon Sep 17 00:00:00 2001 From: Carlos Chitty Date: Tue, 29 Apr 2025 15:19:40 -0400 Subject: [PATCH 2/5] Do not fail tests on deprecation warnings for the next rails version (7.2) --- config/environments/test.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/config/environments/test.rb b/config/environments/test.rb index 2e14aea9c3..abda6964d9 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -54,15 +54,5 @@ Openfoodnetwork::Application.configure do # Print deprecation notices to the stderr # config.active_support.deprecation = :stderr - # Fail tests on deprecated code unless it's a known case to solve. - ActiveSupport::Deprecation.behavior = ->(message, callstack, deprecation_horizon, gem_name) do - allowed_warnings = [ - # List strings here to allow matching deprecations. - ] - unless allowed_warnings.any? { |pattern| message.match(pattern) } - ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:raise].call(message, callstack, deprecation_horizon, gem_name) - end - end - config.active_job.queue_adapter = :test end From a2f263e0811867e824819335e6caa09bec6526fb Mon Sep 17 00:00:00 2001 From: Carlos Chitty Date: Wed, 26 Mar 2025 12:50:43 -0400 Subject: [PATCH 3/5] User Rails.env.local? https://github.com/rails/rails/pull/46786 Solves rubocop failure in rails 7.1 bump branch https://github.com/openfoodfoundation/openfoodnetwork/actions/runs/14739687970/job/41374340281?pr=13232 --- app/controllers/api/v1/base_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/v1/base_controller.rb b/app/controllers/api/v1/base_controller.rb index f1e5e992fb..15a75cc0d1 100644 --- a/app/controllers/api/v1/base_controller.rb +++ b/app/controllers/api/v1/base_controller.rb @@ -54,7 +54,7 @@ module Api def error_during_processing(exception) Alert.raise(exception) - if Rails.env.development? || Rails.env.test? + if Rails.env.local? render status: :unprocessable_entity, json: json_api_error(exception.message, meta: exception.backtrace) else From 3153e99497327ef936fb8776c343c8bfec298362 Mon Sep 17 00:00:00 2001 From: Carlos Chitty Date: Wed, 30 Apr 2025 13:42:36 -0400 Subject: [PATCH 4/5] Update OpenOrderCycleJob test "syncing remote products" to expect 58 queries instead of 59 The main point of the test is to alert us if the query count increased (https://github.com/openfoodfoundation/openfoodnetwork/pull/13232#discussion_r2199896280). The missing query in rails 7.1: Spree::StockItem Load SELECT "spree_stock_items"."id", "spree_stock_items"."variant_id", "spree_stock_items"."count_on_hand", "spree_stock_items"."created_at", "spree_stock_items"."updated_at", "spree_stock_items"."backorderable", "spree_stock_items"."deleted_at", "spree_stock_items"."lock_version" FROM "spree_stock_items" WHERE "spree_stock_items"."id" = $1 LIMIT $2 FOR UPDATE --- spec/jobs/open_order_cycle_job_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/jobs/open_order_cycle_job_spec.rb b/spec/jobs/open_order_cycle_job_spec.rb index bf7c84d5ab..c6d1d1d27e 100644 --- a/spec/jobs/open_order_cycle_job_spec.rb +++ b/spec/jobs/open_order_cycle_job_spec.rb @@ -71,7 +71,7 @@ RSpec.describe OpenOrderCycleJob do .and change { variant.on_demand }.to(true) .and change { variant.on_hand }.by(0) .and change { variant_discontinued.on_hand }.to(0) - .and query_database 59 + .and query_database 58 end end From 45b712ddcdadba11cced15766aa90adcbe32177d Mon Sep 17 00:00:00 2001 From: Carlos Chitty Date: Wed, 30 Apr 2025 14:53:44 -0400 Subject: [PATCH 5/5] Set latest invoce date explicitly in Orders::GenerateInvoiceService test Solves CI failure: https://github.com/openfoodfoundation/openfoodnetwork/actions/runs/14760883756/job/41441014958?pr=13232 --- spec/services/orders/generate_invoice_service_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/services/orders/generate_invoice_service_spec.rb b/spec/services/orders/generate_invoice_service_spec.rb index a396a26897..e818eae266 100644 --- a/spec/services/orders/generate_invoice_service_spec.rb +++ b/spec/services/orders/generate_invoice_service_spec.rb @@ -8,6 +8,7 @@ RSpec.describe Orders::GenerateInvoiceService do let!(:latest_invoice){ create(:invoice, order:, + date: Time.zone.today - 2.days, data: invoice_data_generator.serialize_for_invoice) }