Skip to content

Commit

Permalink
Merge pull request #807 from gucki/rails-7.1
Browse files Browse the repository at this point in the history
Send nil to ActiveSupport#compile which now requires a parameter
  • Loading branch information
jkowens committed Aug 11, 2023
2 parents e3331d5 + 41ba6ba commit e85a287
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ end
gem "factory_bot"
gem "timecop"
gem "chronic"
gem "mocha", "~> 1.3.0"
gem "mocha", "~> 2.1.0"

# Debugging
platforms :jruby do
Expand Down
6 changes: 5 additions & 1 deletion lib/activerecord-import/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ def valid_model?(model)

model.run_callbacks(:validation) do
if defined?(ActiveSupport::Callbacks::Filters::Environment) # ActiveRecord >= 4.1
runner = @validate_callbacks.compile
runner = if @validate_callbacks.method(:compile).arity == 0
@validate_callbacks.compile
else # ActiveRecord >= 7.1
@validate_callbacks.compile(nil)
end
env = ActiveSupport::Callbacks::Filters::Environment.new(model, false, nil)
if runner.respond_to?(:call) # ActiveRecord < 5.1
runner.call(env)
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
require 'mocha/test_unit'
else
require 'active_support/testing/autorun'
require "mocha/mini_test"
require "mocha/minitest"
end

require 'timecop'
Expand Down

0 comments on commit e85a287

Please sign in to comment.