diff --git a/test/rodauth_test.rb b/test/rodauth_test.rb index d314c18..374c4de 100644 --- a/test/rodauth_test.rb +++ b/test/rodauth_test.rb @@ -42,13 +42,17 @@ class RodauthTest < UnitTest if Rails.gem_version >= Gem::Version.new("5.2.0") Rails.application.credentials.secret_key_base = "credential" - assert_equal "credential", Rodauth::Rails.secret_key_base + reset_secret_key_base do + assert_equal "credential", Rodauth::Rails.secret_key_base + end ENV["SECRET_KEY_BASE"] = "environment" - assert_equal "environment", Rodauth::Rails.secret_key_base + reset_secret_key_base do + assert_equal "environment", Rodauth::Rails.secret_key_base + end ENV.delete("SECRET_KEY_BASE") end - + ensure Rails.env = "test" end @@ -114,4 +118,12 @@ class RodauthTest < UnitTest refute_includes app.instance_methods, :render end + + def reset_secret_key_base + original_secret_key_base = Rails.configuration.secret_key_base + Rails.configuration.secret_key_base = nil + yield + ensure + Rails.configuration.secret_key_base = original_secret_key_base + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 905e3b1..90da3ca 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -16,7 +16,9 @@ module TestSetupTeardown def setup super - if ActiveRecord.version >= Gem::Version.new("5.2") + if ActiveRecord.version >= Gem::Version.new("7.2.0.alpha") + ActiveRecord::Base.connection_pool.migration_context.up + elsif ActiveRecord.version >= Gem::Version.new("5.2") ActiveRecord::Base.connection.migration_context.up else ActiveRecord::Migrator.up(Rails.application.paths["db/migrate"].to_a) @@ -25,7 +27,9 @@ def setup def teardown super - if ActiveRecord.version >= Gem::Version.new("5.2") + if ActiveRecord.version >= Gem::Version.new("7.2.0.alpha") + ActiveRecord::Base.connection_pool.migration_context.up + elsif ActiveRecord.version >= Gem::Version.new("5.2") ActiveRecord::Base.connection.migration_context.down else ActiveRecord::Migrator.down(Rails.application.paths["db/migrate"].to_a)