Skip to content

Commit

Permalink
Merge pull request #202 from iknow/rails-7-1
Browse files Browse the repository at this point in the history
Support Rails 7.1
  • Loading branch information
chrisandreae authored Apr 23, 2024
2 parents ee1c0d8 + 3bb13a7 commit a651321
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down
10 changes: 10 additions & 0 deletions gemfiles/rails_7_1.gemfile
Original file line number Diff line number Diff line change
@@ -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: '../'
2 changes: 1 addition & 1 deletion lib/iknow_view_models/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module IknowViewModels
VERSION = '3.9.1'
VERSION = '3.9.2'
end
17 changes: 17 additions & 0 deletions lib/view_model/after_transaction_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions nix/dependencies.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{pkgs}:
{
ruby = pkgs.ruby_3_0;
postgresql = pkgs.postgresql_12;
ruby = pkgs.ruby_3_2;
postgresql = pkgs.postgresql_14;
}

0 comments on commit a651321

Please sign in to comment.