From ee1f243c1135cadba06a18df4faf8cfe83797cab Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Fri, 18 Jul 2025 15:26:49 -0600 Subject: [PATCH 01/10] Update to allow for rails 8 compatibility --- .github/workflows/ci.yml | 18 +++++++++------- gemfiles/Gemfile.rails-8.0-stable | 7 +++++++ polymorphic_integer_type.gemspec | 35 +++++++++++++++++-------------- 3 files changed, 37 insertions(+), 23 deletions(-) create mode 100644 gemfiles/Gemfile.rails-8.0-stable diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4523ebb..6b64b1e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,13 +14,17 @@ jobs: fail-fast: false matrix: gemfile: - - Gemfile.rails-6.1-stable - - Gemfile.rails-7.0-stable - - Gemfile.rails-7.2-stable - ruby-version: ['3.1', '3.0'] - exclude: - - gemfile: Gemfile.rails-7.2-stable - ruby-version: "3.0" + - { gemfile: Gemfile.rails-6.1-stable, ruby-version: '3.0' } + - { gemfile: Gemfile.rails-6.1-stable, ruby-version: '3.1' } + - { gemfile: Gemfile.rails-7.0-stable, ruby-version: '3.1' } + - { gemfile: Gemfile.rails-7.0-stable, ruby-version: '3.2' } + # Rails 7.2 with Ruby 3.1+ + - { gemfile: Gemfile.rails-7.2-stable, ruby-version: '3.1' } + - { gemfile: Gemfile.rails-7.2-stable, ruby-version: '3.2' } + - { gemfile: Gemfile.rails-7.2-stable, ruby-version: '3.3' } + # Rails 8.0 with Ruby 3.2+ + - { gemfile: Gemfile.rails-8.0-stable, ruby-version: '3.2' } + - { gemfile: Gemfile.rails-8.0-stable, ruby-version: '3.3' } env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }} steps: diff --git a/gemfiles/Gemfile.rails-8.0-stable b/gemfiles/Gemfile.rails-8.0-stable new file mode 100644 index 0000000..c486345 --- /dev/null +++ b/gemfiles/Gemfile.rails-8.0-stable @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gemspec path: ".." + +gem "activerecord", github: "rails/rails", branch: "8-0-stable" diff --git a/polymorphic_integer_type.gemspec b/polymorphic_integer_type.gemspec index 52bb61a..babacda 100644 --- a/polymorphic_integer_type.gemspec +++ b/polymorphic_integer_type.gemspec @@ -1,27 +1,30 @@ -# coding: utf-8 -lib = File.expand_path('../lib', __FILE__) +# frozen_string_literal: true + +lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'polymorphic_integer_type/version' Gem::Specification.new do |spec| - spec.name = "polymorphic_integer_type" + spec.name = 'polymorphic_integer_type' spec.version = PolymorphicIntegerType::VERSION - spec.authors = ["Kyle d'Oliveira"] - spec.email = ["kyle@goclio.com"] - spec.description = %q{Allows the *_type field in the DB to be an integer rather than a string} - spec.summary = %q{Use integers rather than strings for the _type field} - spec.homepage = "" - spec.license = "MIT" + spec.authors = ['Kyle d\'Oliveira'] + spec.email = ['kyle@goclio.com'] + spec.description = 'Allows the *_type field in the DB to be an integer rather than a string' + spec.summary = 'Use integers rather than strings for the _type field' + spec.homepage = '' + spec.license = 'MIT' + + spec.required_ruby_version = '>= 3.0' spec.files = `git ls-files -- . ':!.github/'`.split($/) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) - spec.require_paths = ["lib"] + spec.require_paths = ['lib'] - spec.add_dependency "activerecord", "< 8" - spec.add_development_dependency "bundler" - spec.add_development_dependency "rake" - spec.add_development_dependency "rspec" - spec.add_development_dependency "sqlite3" - spec.add_development_dependency "pry-byebug" + spec.add_dependency 'activerecord', '< 9.0' + spec.add_development_dependency 'bundler' + spec.add_development_dependency 'pry-byebug' + spec.add_development_dependency 'rake' + spec.add_development_dependency 'rspec' + spec.add_development_dependency 'sqlite3' end From 25e118a63fef66d228f07bc91b6104b2cf467fc7 Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Fri, 18 Jul 2025 15:27:01 -0600 Subject: [PATCH 02/10] update gem version --- CHANGELOG.md | 5 +++++ lib/polymorphic_integer_type/version.rb | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e66bf5..01c47e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,3 +26,8 @@ - Remove unsupported rails versions(5.0, 5.2, 6.0) and ruby version(2.7) +## v3.4.0 (2024-XX-XX) + +### Added + +- Add Rails 8.0 compatibility (requires Ruby 3.2+) \ No newline at end of file diff --git a/lib/polymorphic_integer_type/version.rb b/lib/polymorphic_integer_type/version.rb index febae78..41a41aa 100644 --- a/lib/polymorphic_integer_type/version.rb +++ b/lib/polymorphic_integer_type/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module PolymorphicIntegerType - VERSION = "3.3.0" + VERSION = '3.4.0.pre' end From dedd446612a02b1f7fb74bfc78cb6b5b4f705222 Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Fri, 18 Jul 2025 15:27:22 -0600 Subject: [PATCH 03/10] modify rakefile to support both sqlite3 and mysql --- Rakefile | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index cb6b440..0479f58 100644 --- a/Rakefile +++ b/Rakefile @@ -15,34 +15,59 @@ end namespace :db do database_config = YAML.load(File.open("./spec/support/database.yml")) - admin_database_config = database_config.merge(database: "mysql") migration_path = File.expand_path("./spec/support/migrations") desc "Create the database" task :create do - ActiveRecord::Base.establish_connection(admin_database_config) - ActiveRecord::Base.connection.create_database(database_config.fetch(:database)) - puts "Database created." + if database_config[:adapter] == 'sqlite3' + # For SQLite3, just ensure the directory exists + db_file = database_config.fetch(:database) + FileUtils.mkdir_p(File.dirname(db_file)) unless File.dirname(db_file) == '.' + puts "Database created (SQLite3 will create file on first connection)." + else + # For other databases (MySQL, PostgreSQL, etc.) + admin_config = database_config.merge(database: "mysql") + ActiveRecord::Base.establish_connection(admin_config) + ActiveRecord::Base.connection.create_database(database_config.fetch(:database)) + puts "Database created." + end end desc "Migrate the database" task :migrate do ActiveRecord::Base.establish_connection(database_config) - ActiveRecord::Migrator.migrate(migration_path) + + # Handle different Rails versions + active_record_version = Gem::Version.new(ActiveRecord::VERSION::STRING) + + if active_record_version >= Gem::Version.new("6.0") + ActiveRecord::MigrationContext.new(migration_path).migrate + else + ActiveRecord::Migrator.migrate(migration_path) + end + Rake::Task["db:schema"].invoke puts "Database migrated." end desc "Drop the database" task :drop do - ActiveRecord::Base.establish_connection(admin_database_config) - ActiveRecord::Base.connection.drop_database(database_config.fetch(:database)) + if database_config[:adapter] == 'sqlite3' + # For SQLite3, just delete the file + db_file = database_config.fetch(:database) + File.delete(db_file) if File.exist?(db_file) + else + # For other databases (MySQL, PostgreSQL, etc.) + admin_config = database_config.merge(database: "mysql") + ActiveRecord::Base.establish_connection(admin_config) + ActiveRecord::Base.connection.drop_database(database_config.fetch(:database)) + end puts "Database deleted." end desc "Reset the database" task reset: [:drop, :create, :migrate] - desc 'Create a db/schema.rb file that is portable against any DB supported by AR' + desc 'Create a db/schema.rb file that is portable against any DB supported by AR' task :schema do # Noop to make ActiveRecord happy From b580d147ff48c2e667482b38c86d1df00b93026b Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Fri, 18 Jul 2025 15:42:49 -0600 Subject: [PATCH 04/10] modify the test matrix --- .github/workflows/ci.yml | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b64b1e..58a3d44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,17 +14,23 @@ jobs: fail-fast: false matrix: gemfile: - - { gemfile: Gemfile.rails-6.1-stable, ruby-version: '3.0' } - - { gemfile: Gemfile.rails-6.1-stable, ruby-version: '3.1' } - - { gemfile: Gemfile.rails-7.0-stable, ruby-version: '3.1' } - - { gemfile: Gemfile.rails-7.0-stable, ruby-version: '3.2' } - # Rails 7.2 with Ruby 3.1+ - - { gemfile: Gemfile.rails-7.2-stable, ruby-version: '3.1' } - - { gemfile: Gemfile.rails-7.2-stable, ruby-version: '3.2' } - - { gemfile: Gemfile.rails-7.2-stable, ruby-version: '3.3' } - # Rails 8.0 with Ruby 3.2+ - - { gemfile: Gemfile.rails-8.0-stable, ruby-version: '3.2' } - - { gemfile: Gemfile.rails-8.0-stable, ruby-version: '3.3' } + - Gemfile.rails-6.1-stable + - Gemfile.rails-7.0-stable + - Gemfile.rails-7.2-stable + - Gemfile.rails-8.0-stable + ruby-version: ['3.0', '3.1', '3.2', '3.3'] + exclude: + # Rails 7.0 doesn't work with Ruby 3.0 + - gemfile: Gemfile.rails-7.0-stable + ruby-version: '3.0' + # Rails 7.2 doesn't work with Ruby 3.0 + - gemfile: Gemfile.rails-7.2-stable + ruby-version: '3.0' + # Rails 8.0 doesn't work with Ruby 3.0 or 3.1 + - gemfile: Gemfile.rails-8.0-stable + ruby-version: '3.0' + - gemfile: Gemfile.rails-8.0-stable + ruby-version: '3.1' env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }} steps: From 1c77aa048a4a3505a0b5a6aea1898ef0ed2e3768 Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Fri, 18 Jul 2025 15:55:09 -0600 Subject: [PATCH 05/10] cleanup Rakefile --- Rakefile | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/Rakefile b/Rakefile index 0479f58..3545c50 100644 --- a/Rakefile +++ b/Rakefile @@ -1,56 +1,57 @@ -require "bundler/gem_tasks" -require "yaml" -require "active_record" +require 'bundler/gem_tasks' +require 'yaml' +require 'active_record' namespace :test do task :all do - Dir.glob("./gemfiles/Gemfile*").each do |gemfile| - next if gemfile.end_with?(".lock") + Dir.glob('./gemfiles/Gemfile*').each do |gemfile| + next if gemfile.end_with?('.lock') + puts "Running specs for #{Pathname.new(gemfile).basename}" system("BUNDLE_GEMFILE=#{gemfile} bundle install > /dev/null && BUNDLE_GEMFILE=#{gemfile} bundle exec rspec") - puts "" + puts '' end end end namespace :db do - database_config = YAML.load(File.open("./spec/support/database.yml")) - migration_path = File.expand_path("./spec/support/migrations") + database_config = YAML.load(File.open('./spec/support/database.yml')) + migration_path = File.expand_path('./spec/support/migrations') - desc "Create the database" + desc 'Create the database' task :create do if database_config[:adapter] == 'sqlite3' # For SQLite3, just ensure the directory exists db_file = database_config.fetch(:database) FileUtils.mkdir_p(File.dirname(db_file)) unless File.dirname(db_file) == '.' - puts "Database created (SQLite3 will create file on first connection)." + puts 'Database created (SQLite3 will create file on first connection).' else # For other databases (MySQL, PostgreSQL, etc.) admin_config = database_config.merge(database: "mysql") ActiveRecord::Base.establish_connection(admin_config) ActiveRecord::Base.connection.create_database(database_config.fetch(:database)) - puts "Database created." + puts 'Database created.' end end - desc "Migrate the database" + desc 'Migrate the database' task :migrate do ActiveRecord::Base.establish_connection(database_config) - + # Handle different Rails versions active_record_version = Gem::Version.new(ActiveRecord::VERSION::STRING) - + if active_record_version >= Gem::Version.new("6.0") ActiveRecord::MigrationContext.new(migration_path).migrate else ActiveRecord::Migrator.migrate(migration_path) end - - Rake::Task["db:schema"].invoke - puts "Database migrated." + + Rake::Task['db:schema'].invoke + puts 'Database migrated.' end - desc "Drop the database" + desc 'Drop the database' task :drop do if database_config[:adapter] == 'sqlite3' # For SQLite3, just delete the file @@ -62,10 +63,10 @@ namespace :db do ActiveRecord::Base.establish_connection(admin_config) ActiveRecord::Base.connection.drop_database(database_config.fetch(:database)) end - puts "Database deleted." + puts 'Database deleted.' end - desc "Reset the database" + desc 'Reset the database' task reset: [:drop, :create, :migrate] desc 'Create a db/schema.rb file that is portable against any DB supported by AR' From 3e4bbc80fdfa1e093a032be4141501c8c10d81c6 Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Fri, 18 Jul 2025 16:01:34 -0600 Subject: [PATCH 06/10] Use sqlite3 for tests --- README.md | 9 ++++++++- Rakefile | 31 +++++++++---------------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 5d72bd9..d868789 100644 --- a/README.md +++ b/README.md @@ -144,10 +144,17 @@ You'll need to have git, Ruby, and MySQL. Then get up and running with a few com $ git clone ... $ bundle install $ vim spec/support/database.yml # Update username and password -$ bin/setup +$ bin/setup # Uses SQLite3 for testing (no additional setup required) $ bundle exec rspec ``` +## Database Compatibility + +This gem works with any database supported by ActiveRecord (SQLite3, MySQL, PostgreSQL, etc.). +The gem extends ActiveRecord's polymorphic associations and doesn't use database-specific features. + +Development and testing uses SQLite3 for simplicity. + ## Contributing 1. Fork it diff --git a/Rakefile b/Rakefile index 3545c50..dcc96aa 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/gem_tasks' require 'yaml' require 'active_record' @@ -20,18 +22,10 @@ namespace :db do desc 'Create the database' task :create do - if database_config[:adapter] == 'sqlite3' - # For SQLite3, just ensure the directory exists - db_file = database_config.fetch(:database) - FileUtils.mkdir_p(File.dirname(db_file)) unless File.dirname(db_file) == '.' - puts 'Database created (SQLite3 will create file on first connection).' - else - # For other databases (MySQL, PostgreSQL, etc.) - admin_config = database_config.merge(database: "mysql") - ActiveRecord::Base.establish_connection(admin_config) - ActiveRecord::Base.connection.create_database(database_config.fetch(:database)) - puts 'Database created.' - end + # SQLite3 creates the database file automatically, just ensure directory exists + db_file = database_config.fetch(:database) + FileUtils.mkdir_p(File.dirname(db_file)) unless File.dirname(db_file) == '.' + puts 'Database ready (SQLite3).' end desc 'Migrate the database' @@ -53,16 +47,9 @@ namespace :db do desc 'Drop the database' task :drop do - if database_config[:adapter] == 'sqlite3' - # For SQLite3, just delete the file - db_file = database_config.fetch(:database) - File.delete(db_file) if File.exist?(db_file) - else - # For other databases (MySQL, PostgreSQL, etc.) - admin_config = database_config.merge(database: "mysql") - ActiveRecord::Base.establish_connection(admin_config) - ActiveRecord::Base.connection.drop_database(database_config.fetch(:database)) - end + # For SQLite3, just delete the file + db_file = database_config.fetch(:database) + File.delete(db_file) if File.exist?(db_file) puts 'Database deleted.' end From b53ea61690b8d8bb8fff0cc558ac73ab87d09208 Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Fri, 18 Jul 2025 16:02:08 -0600 Subject: [PATCH 07/10] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d868789..14573c1 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ Lastly, you will need to be careful of any place where you are doing raw SQL que ## Setup -You'll need to have git, Ruby, and MySQL. Then get up and running with a few commands: +You'll need to have git and Ruby. Then get up and running with a few commands: ```bash $ git clone ... From da258ba9e6a17ccb7cb7dcb97bbde9c4a91071dc Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Fri, 18 Jul 2025 16:07:53 -0600 Subject: [PATCH 08/10] set version to 3.4 --- lib/polymorphic_integer_type/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/polymorphic_integer_type/version.rb b/lib/polymorphic_integer_type/version.rb index 41a41aa..c1e9c4d 100644 --- a/lib/polymorphic_integer_type/version.rb +++ b/lib/polymorphic_integer_type/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module PolymorphicIntegerType - VERSION = '3.4.0.pre' + VERSION = '3.4.0' end From 1f7851997d3d0e2ecb735275ea8fe14b85027a0b Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Mon, 21 Jul 2025 10:13:16 -0600 Subject: [PATCH 09/10] remove rails 6.x support --- .github/workflows/ci.yml | 1 - CHANGELOG.md | 5 ++++- Rakefile | 11 +---------- gemfiles/Gemfile.rails-6.1-stable | 8 -------- .../polymorphic_array_value_extension.rb | 6 +----- .../belongs_to_polymorphic_association_extension.rb | 13 +++---------- lib/polymorphic_integer_type/extensions.rb | 7 +------ spec/spec_helper.rb | 9 +-------- 8 files changed, 11 insertions(+), 49 deletions(-) delete mode 100644 gemfiles/Gemfile.rails-6.1-stable diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58a3d44..792e98e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,6 @@ jobs: fail-fast: false matrix: gemfile: - - Gemfile.rails-6.1-stable - Gemfile.rails-7.0-stable - Gemfile.rails-7.2-stable - Gemfile.rails-8.0-stable diff --git a/CHANGELOG.md b/CHANGELOG.md index 01c47e1..47b6efe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,4 +30,7 @@ ### Added -- Add Rails 8.0 compatibility (requires Ruby 3.2+) \ No newline at end of file +- Add Rails 8.0 compatibility (requires Ruby 3.2+) + +### Removed +- Remove unsupported rails versions 6.x \ No newline at end of file diff --git a/Rakefile b/Rakefile index dcc96aa..39eb26e 100644 --- a/Rakefile +++ b/Rakefile @@ -31,16 +31,7 @@ namespace :db do desc 'Migrate the database' task :migrate do ActiveRecord::Base.establish_connection(database_config) - - # Handle different Rails versions - active_record_version = Gem::Version.new(ActiveRecord::VERSION::STRING) - - if active_record_version >= Gem::Version.new("6.0") - ActiveRecord::MigrationContext.new(migration_path).migrate - else - ActiveRecord::Migrator.migrate(migration_path) - end - + ActiveRecord::MigrationContext.new(migration_path).migrate Rake::Task['db:schema'].invoke puts 'Database migrated.' end diff --git a/gemfiles/Gemfile.rails-6.1-stable b/gemfiles/Gemfile.rails-6.1-stable deleted file mode 100644 index 5056859..0000000 --- a/gemfiles/Gemfile.rails-6.1-stable +++ /dev/null @@ -1,8 +0,0 @@ -# frozen_string_literal: true - -source "https://rubygems.org" - -gemspec path: ".." - -gem "activerecord", github: "rails/rails", branch: "6-1-stable" -gem "sqlite3", "~> 1.4" diff --git a/lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb b/lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb index df57836..1f44ce2 100644 --- a/lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb +++ b/lib/polymorphic_integer_type/activerecord_5_0_0/polymorphic_array_value_extension.rb @@ -10,11 +10,7 @@ module PolymorphicArrayValueExtension # end def type_to_ids_mapping - if ACTIVE_RECORD_VERSION < Gem::Version.new("6.1") - association = @associated_table.send(:association) - else - association = @associated_table.send(:reflection) - end + association = @associated_table.send(:reflection) name = association.name default_hash = Hash.new { |hsh, key| hsh[key] = [] } diff --git a/lib/polymorphic_integer_type/belongs_to_polymorphic_association_extension.rb b/lib/polymorphic_integer_type/belongs_to_polymorphic_association_extension.rb index 8840fc2..5671294 100644 --- a/lib/polymorphic_integer_type/belongs_to_polymorphic_association_extension.rb +++ b/lib/polymorphic_integer_type/belongs_to_polymorphic_association_extension.rb @@ -3,16 +3,9 @@ module Associations class BelongsToPolymorphicAssociation < BelongsToAssociation private - if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("6.1") - def replace_keys(record) - super - owner[reflection.foreign_type] = record.class.base_class unless record.nil? - end - elsif - def replace_keys(record, force: false) - super - owner[reflection.foreign_type] = record.class.base_class unless record.nil? - end + def replace_keys(record, force: false) + super + owner[reflection.foreign_type] = record.class.base_class unless record.nil? end end end diff --git a/lib/polymorphic_integer_type/extensions.rb b/lib/polymorphic_integer_type/extensions.rb index c6c1389..8e2144f 100644 --- a/lib/polymorphic_integer_type/extensions.rb +++ b/lib/polymorphic_integer_type/extensions.rb @@ -118,12 +118,7 @@ def remove_integer_type_and_set_attributes_and_extension(integer_type_values, re if is_polymorphic_integer reflection.foreign_integer_type = foreign_integer_type reflection.integer_type = integer_type - - if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("6.1") - ActiveRecord::Associations::Association.prepend(PolymorphicIntegerType::PolymorphicForeignAssociationExtension) - else - ActiveRecord::Associations::ForeignAssociation.prepend(PolymorphicIntegerType::PolymorphicForeignAssociationExtension) - end + ActiveRecord::Associations::ForeignAssociation.prepend(PolymorphicIntegerType::PolymorphicForeignAssociationExtension) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fdcbd3d..192de66 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -20,17 +20,10 @@ config.before(:suite) do database_config = YAML.load(File.open("#{File.dirname(__FILE__)}/support/database.yml")) migrations_path = "#{File.dirname(__FILE__)}/support/migrations" - active_record_version = Gem::Version.new(ActiveRecord::VERSION::STRING) ActiveRecord::Base.establish_connection(database_config) - - if active_record_version >= Gem::Version.new("6.1") && active_record_version < Gem::Version.new("7.0") - ActiveRecord::MigrationContext.new(migrations_path, ActiveRecord::SchemaMigration).migrate - end - if active_record_version >= Gem::Version.new("7.0") - ActiveRecord::MigrationContext.new(migrations_path).migrate - end + ActiveRecord::MigrationContext.new(migrations_path).migrate end config.around do |example| From 60a61972324927912c1a314c846f653d0291b234 Mon Sep 17 00:00:00 2001 From: Parsa Honarmand Date: Mon, 21 Jul 2025 10:28:17 -0600 Subject: [PATCH 10/10] Test rails 7 with ruby 3.0 --- .github/workflows/ci.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 792e98e..5d13f30 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,13 +19,10 @@ jobs: - Gemfile.rails-8.0-stable ruby-version: ['3.0', '3.1', '3.2', '3.3'] exclude: - # Rails 7.0 doesn't work with Ruby 3.0 - - gemfile: Gemfile.rails-7.0-stable - ruby-version: '3.0' - # Rails 7.2 doesn't work with Ruby 3.0 + # Rails 7.2 doesn't work with Ruby 3.0 (requires Ruby 3.1+) - gemfile: Gemfile.rails-7.2-stable ruby-version: '3.0' - # Rails 8.0 doesn't work with Ruby 3.0 or 3.1 + # Rails 8.0 doesn't work with Ruby 3.0 or 3.1 (requires Ruby 3.2+) - gemfile: Gemfile.rails-8.0-stable ruby-version: '3.0' - gemfile: Gemfile.rails-8.0-stable