authlogic icon indicating copy to clipboard operation
authlogic copied to clipboard

Authlogic is incompatible with Minitest v5.19.0 and later

Open toncid opened this issue 2 years ago • 3 comments

ISSUES THAT DO NOT FOLLOW THIS TEMPLATE WILL BE CLOSED IMMEDIATELY.

  • [x] This is not a usage question.
    • Our volunteers' time is limited, so please ask usage questions on StackOverflow.
  • [x] This is not a security issue.
  • [x] This bug is reproducible with a clean install of authlogic
  • [x] I am committed to fixing this in a reasonable amount of time, and responding promptly to feedback.

Expected Behavior

The authlogic/test_case.rb should be extended with the following includes:

module Authlogic
  module TestCase
    ...
  end

  ...

  # new includes
  ::Minitest::Unit::TestCase.send(:include, TestCase) if defined?(::Minitest::Unit::TestCase)
  ::Minitest::Test.send(:include, TestCase) if defined?(::Minitest::Test)
end

Actual Behavior

Tests fail because Minitest removed a legacy compatibility layer in v5.19.0 and test classes are no longer included.

toncid avatar Aug 23 '23 13:08 toncid

I'm having some trouble running tests on a Rails app that I'm upgrading from Rails 5 to Rails 7 and ended up here. Authlogic gets in between of some ActiveAdmin classes and breaks everything.

I thought these includes you propose may be missing, but I see them in Authlogic's code already -> https://github.com/binarylogic/authlogic/blame/master/lib/authlogic/test_case.rb#L213

ceneon avatar Mar 14 '24 22:03 ceneon

Yes, the fix should be simple and something like:

module Authlogic
  ...

  if defined?(::Minitest)
    ::Minitest::Unit::TestCase.send(:include, TestCase) if defined?(::Minitest::Unit::TestCase)
    ::Minitest::Test.send(:include, TestCase) if defined?(::Minitest::Test)
  elsif defined?(::MiniTest) # for Minitest < 5.19.0
    ::MiniTest::Unit::TestCase.send(:include, TestCase) if defined?(::MiniTest::Unit::TestCase)
    ::MiniTest::Test.send(:include, TestCase) if defined?(::MiniTest::Test)
  end
end

toncid avatar Mar 15 '24 08:03 toncid

Thank you for this. Ended up here also following an early Rails 6 to Rails 7 upgrade path. My specific issue was that I had an "activate_authlogic" method missing error and adding your proposed includes to an initializer fixed the problem.

robinjfisher avatar May 18 '24 15:05 robinjfisher