diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1d8b7c6..bde4cfc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,13 +28,24 @@ jobs: strategy: matrix: ruby: - - "3.0" - - "3.1" - "3.2" - "3.3" rails: - - "7.0" - - "7.1" + - "7.0.8.4" + - "7.1.4" + - "7.2.1" + - "8.0.0.beta1" + include: + - rails: "7.0.8.4" + ruby: "3.0" + - rails: "7.0.8.4" + ruby: "3.1" + - rails: "7.1.4" + ruby: "3.0" + - rails: "7.1.4" + ruby: "3.1" + - rails: "7.2.1" + ruby: "3.1" steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9186208..482c1fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.16.0 + +- Rails 8 support introduced + ## 0.15.0 - *Breaking Change* - Support for Ruby 2.7 and Rails 6.1 is dropped diff --git a/Gemfile b/Gemfile index ee6cf3f..ac31ad3 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" gem "debug" if (rails_version = ENV["RAILS_VERSION"]) - gem "rails", "~> #{rails_version}.0" + gem "rails", "~> #{rails_version}" else gem "rails" end diff --git a/README.md b/README.md index 0f88b66..2a2d744 100644 --- a/README.md +++ b/README.md @@ -496,6 +496,14 @@ Instead of storing the previous versions or changes in a separate table, it stor proprietary JSON format directly on the database row of the record itself. If does not support soft deletion. +## Testing + +Hoardable is tested against a matrix of Ruby 3 versions and Rails 7 & 8. To run tests locally, run: + +``` +rake +``` + ## Contributing Bug reports and pull requests are welcome on GitHub at https://github.com/waymondo/hoardable. diff --git a/hoardable.gemspec b/hoardable.gemspec index da23132..c7d6efd 100644 --- a/hoardable.gemspec +++ b/hoardable.gemspec @@ -30,9 +30,9 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "activerecord", ">= 7", "< 8" - spec.add_dependency "activesupport", ">= 7", "< 8" - spec.add_dependency "railties", ">= 7", "< 8" + spec.add_dependency "activerecord", ">= 7" + spec.add_dependency "activesupport", ">= 7" + spec.add_dependency "railties", ">= 7" spec.add_dependency "fx", ">= 0.8", "< 1" spec.add_dependency "pg", ">= 1", "< 2" diff --git a/lib/hoardable/has_one.rb b/lib/hoardable/has_one.rb index bf82ca2..a31c87b 100644 --- a/lib/hoardable/has_one.rb +++ b/lib/hoardable/has_one.rb @@ -9,13 +9,13 @@ module HasOne def has_one(*args) options = args.extract_options! hoardable = options.delete(:hoardable) - association = super(*args, **options) name = args.first - return unless hoardable || association[name.to_s].options[:class_name].match?(/RichText$/) + association = super(*args, **options).symbolize_keys[name] + return unless hoardable || (association.options[:class_name].match?(/RichText$/)) class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} - reflection = _reflections['#{name}'] + reflection = _reflections.symbolize_keys[:#{name}] return super if reflection.klass.name.match?(/^ActionText/) return super unless (timestamp = hoardable_client.has_one_at_timestamp) diff --git a/lib/hoardable/schema_statements.rb b/lib/hoardable/schema_statements.rb index 4743fd1..98fd45c 100644 --- a/lib/hoardable/schema_statements.rb +++ b/lib/hoardable/schema_statements.rb @@ -4,7 +4,7 @@ module Hoardable module SchemaStatements def table_options(table_name) options = super || {} - if inherited_table_names = parent_table_names(table_name) + if !options[:options] && (inherited_table_names = parent_table_names(table_name)) options[:options] = "INHERITS (#{inherited_table_names.join(", ")})" end options diff --git a/lib/hoardable/version.rb b/lib/hoardable/version.rb index 4e7b158..ee5de16 100644 --- a/lib/hoardable/version.rb +++ b/lib/hoardable/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Hoardable - VERSION = "0.15.1" + VERSION = "0.16.0" end diff --git a/test/test_schema_dumper.rb b/test/test_schema_dumper.rb index 6b3e3f6..034ac57 100644 --- a/test/test_schema_dumper.rb +++ b/test/test_schema_dumper.rb @@ -32,7 +32,11 @@ class TestSchemaDumper < ActiveSupport::TestCase private def dump_table_schema(*table_names) connection = ActiveRecord::Base.connection ActiveRecord::SchemaDumper.ignore_tables = connection.data_sources - table_names - stream = StringIO.new - ActiveRecord::SchemaDumper.dump(connection, stream).string + if ActiveRecord.version >= Gem::Version.new("7.2.1") + output, = capture_io { ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool) } + output + else + ActiveRecord::SchemaDumper.dump(connection, StringIO.new).string + end end end