Skip to content

Commit

Permalink
Merge pull request #107 from byroot/update-test-matrix
Browse files Browse the repository at this point in the history
Fix compatibility with Rails 7.2.0.alpha
  • Loading branch information
casperisfine authored Feb 28, 2024
2 parents c6a5c74 + 043555d commit 8d95c66
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ['2.7', '3.0', '3.1', '3.2']
rails: ['6.1', '7.0', 'edge']
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3']
rails: ['6.1', '7.0', '7.1', 'edge']
timezone_aware: [0, 1]
exclude:
- ruby: '3.2'
rails: '6.1'
- ruby: '3.3'
rails: '6.1'
- ruby: '2.7'
rails: 'edge'
- ruby: '3.0'
rails: 'edge'
env:
BUNDLE_GEMFILE: gemfiles/Gemfile.ar-${{ matrix.rails }}
TIMEZONE_AWARE: ${{ matrix.timezone_aware }}
Expand Down
5 changes: 5 additions & 0 deletions gemfiles/Gemfile.ar-7.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gemspec path: '..'

gem 'activerecord', '~> 7.0.0'
7 changes: 6 additions & 1 deletion lib/active_record/typed_store/extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def typed_store(store_attribute, options={}, &block)
typed_klass = TypedHash.create(dsl.fields.values)
const_set("#{store_attribute}_hash".camelize, typed_klass)

if ActiveRecord.version >= Gem::Version.new('6.1.0.alpha')
if ActiveRecord.version >= Gem::Version.new('7.2.0.alpha')
decorate_attributes([store_attribute]) do |name, subtype|
subtype = subtype.subtype if subtype.is_a?(Type)
Type.new(typed_klass, dsl.coder, subtype)
end
elsif ActiveRecord.version >= Gem::Version.new('6.1.0.alpha')
attribute(store_attribute) do |subtype|
subtype = subtype.subtype if subtype.is_a?(Type)
Type.new(typed_klass, dsl.coder, subtype)
Expand Down
4 changes: 2 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
Time.zone = 'UTC'

if ActiveRecord.respond_to?(:yaml_column_permitted_classes)
ActiveRecord.yaml_column_permitted_classes |= ['Date', 'Time', 'BigDecimal']
ActiveRecord.yaml_column_permitted_classes |= [Date, Time, BigDecimal]
elsif ActiveRecord::Base.respond_to?(:yaml_column_permitted_classes)
ActiveRecord::Base.yaml_column_permitted_classes |= ['Date', 'Time', 'BigDecimal']
ActiveRecord::Base.yaml_column_permitted_classes |= [Date, Time, BigDecimal]
end

RSpec.configure do |config|
Expand Down

0 comments on commit 8d95c66

Please sign in to comment.