Skip to content

Commit

Permalink
Fix postgres migration issue in spec helper under Rails 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrictson committed Aug 11, 2024
1 parent 83bab73 commit c7a002c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion spec/audited_spec_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_versions(n = 2, attrs = {})
def run_migrations(direction, migrations_paths, target_version = nil)
if rails_below?("5.2.0.rc1")
ActiveRecord::Migrator.send(direction, migrations_paths, target_version)
elsif rails_below?("6.0.0.rc1")
elsif rails_below?("6.0.0.rc1") || rails_at_least?("7.2.0")
ActiveRecord::MigrationContext.new(migrations_paths).send(direction, target_version)
else
ActiveRecord::MigrationContext.new(migrations_paths, ActiveRecord::SchemaMigration).send(direction, target_version)
Expand All @@ -33,4 +33,8 @@ def run_migrations(direction, migrations_paths, target_version = nil)
def rails_below?(rails_version)
Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new(rails_version)
end

def rails_at_least?(rails_version)
Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new(rails_version)
end
end

0 comments on commit c7a002c

Please sign in to comment.