From aebae057149800230044e69c644129af6eb6161c Mon Sep 17 00:00:00 2001 From: Chris Andreae Date: Mon, 22 Apr 2024 15:05:58 +0900 Subject: [PATCH 1/4] Support Rails 7.1 in AfterTransactionRunner By declaring whether the first or last of equivalent enqueued hooks should be run --- lib/view_model/after_transaction_runner.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/view_model/after_transaction_runner.rb b/lib/view_model/after_transaction_runner.rb index 007b37bd..497de7ac 100644 --- a/lib/view_model/after_transaction_runner.rb +++ b/lib/view_model/after_transaction_runner.rb @@ -4,6 +4,23 @@ # `add_to_transaction`, the abstract method `after_transaction` will be invoked # by AR's callbacks. module ViewModel::AfterTransactionRunner + extend ActiveSupport::Concern + + class_methods do + # Rails 7.1+ expects after transaction hooks to declare whether to run the + # hook on the first equivalent instance to be enqueued or the last one. For + # ActiveRecord models, this class method is defined on ActiveRecord::Core + # and delegates to Rails configuration. For us, we don't expect multiple + # equivalent AfterTransactionRunners for the same callback, and opting into + # the new behaviour would require implementing more of the ActiveRecord + # model interface here such as #destroyed?, so we'll lock in the older + # behavior that doesn't require so many inapplicable heuristics to identify + # the last valid callback. + def run_commit_callbacks_on_first_saved_instances_in_transaction + true + end + end + # Rails' internal API def committed!(*) after_commit From 1fab314a3760a5a53dc7ef94a4f3d5b36b0de522 Mon Sep 17 00:00:00 2001 From: Chris Andreae Date: Mon, 22 Apr 2024 15:09:34 +0900 Subject: [PATCH 2/4] Test with Rails 7.1 on Ruby 3.3 --- .github/workflows/test.yml | 4 +++- gemfiles/rails_7_1.gemfile | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gemfiles/rails_7_1.gemfile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 07f5d1e3..97b94030 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: strategy: fail-fast: false matrix: - ruby-version: ['2.7', '3.0', '3.1', '3.2'] + ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3'] include: - ruby-version: '2.7' bundle-gemfile: gemfiles/rails_5_2.gemfile @@ -36,6 +36,8 @@ jobs: bundle-gemfile: gemfiles/rails_6_1.gemfile - ruby-version: '3.2' bundle-gemfile: gemfiles/rails_7_0.gemfile + - ruby-version: '3.3' + bundle-gemfile: gemfiles/rails_7_1.gemfile env: # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.bundle-gemfile }} diff --git a/gemfiles/rails_7_1.gemfile b/gemfiles/rails_7_1.gemfile new file mode 100644 index 00000000..bd41bb72 --- /dev/null +++ b/gemfiles/rails_7_1.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem 'minitest-ci' +gem "activerecord", "~> 7.1.0" +gem "activesupport", "~> 7.1.0" +gem "actionpack", "~> 7.1.0" + +gemspec path: '../' From 5170389439c020edc04743ed5984519754deea38 Mon Sep 17 00:00:00 2001 From: Chris Andreae Date: Mon, 22 Apr 2024 15:06:44 +0900 Subject: [PATCH 3/4] Bump gem version --- lib/iknow_view_models/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iknow_view_models/version.rb b/lib/iknow_view_models/version.rb index 67d37cb0..be31530c 100644 --- a/lib/iknow_view_models/version.rb +++ b/lib/iknow_view_models/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module IknowViewModels - VERSION = '3.9.1' + VERSION = '3.9.2' end From 3bb13a7174aa30b405e5d5e750c8747319811510 Mon Sep 17 00:00:00 2001 From: Chris Andreae Date: Tue, 23 Apr 2024 15:04:09 +0900 Subject: [PATCH 4/4] Update nix shell dependencies --- nix/dependencies.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/dependencies.nix b/nix/dependencies.nix index ef3347af..bd8ea8c4 100644 --- a/nix/dependencies.nix +++ b/nix/dependencies.nix @@ -1,5 +1,5 @@ {pkgs}: { - ruby = pkgs.ruby_3_0; - postgresql = pkgs.postgresql_12; + ruby = pkgs.ruby_3_2; + postgresql = pkgs.postgresql_14; }