Skip to content

Commit

Permalink
Fix the test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Nov 3, 2022
1 parent 0b1d3ff commit fa079ed
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }}
name: ${{ matrix.ruby }} / Rails ${{ matrix.rails }} / TZ ${{ matrix.timezone_aware }}
strategy:
fail-fast: false
matrix:
ruby: ['2.7', '3.0', '3.1']
gemfile: [Gemfile.ar-6.1, Gemfile.ar-7.0, Gemfile.ar-master]
rails: ['6.1', '7.0', 'edge']
timezone_aware: [0, 1]
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}
BUNDLE_GEMFILE: gemfiles/Gemfile.ar-${{ matrix.rails }}
TIMEZONE_AWARE: ${{ matrix.timezone_aware }}
POSTGRES: 1
MYSQL: 1
POSTGRES_JSON: 1
steps:
- name: Check out code
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion spec/active_record/typed_store_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@

it 'nested hashes are not serialized as HashWithIndifferentAccess' do
model = described_class.create!
expect(model.settings_before_type_cast).not_to include('HashWithIndifferentAccess')
expect(model.settings_before_type_cast.to_s).not_to include('HashWithIndifferentAccess')
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@

Time.zone = 'UTC'

if ActiveRecord.respond_to?(:yaml_column_permitted_classes)
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']
end

RSpec.configure do |config|
config.order = 'random'
end
12 changes: 7 additions & 5 deletions spec/support/models.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'active_record'
require 'base64'
require 'json'
require 'yaml'

Expand All @@ -12,7 +13,7 @@
}
}

def define_columns(t)
def define_columns(t, array: false)
t.integer :no_default

t.string :name, default: '', null: false
Expand Down Expand Up @@ -40,11 +41,12 @@ def define_columns(t)
t.decimal :total_price, default: 4.2, null: false, precision: 16, scale: 2
t.decimal :shipping_cost, precision: 16, scale: 2

t.integer :grades, array: true
if t.is_a?(ActiveRecord::TypedStore::DSL)
t.integer :grades, array: true
t.string :tags, array: true, null: false, default: [].to_yaml

t.string :tags, array: true, null: false, default: [].to_yaml

t.string :nickname, blank: false, default: 'Please enter your nickname'
t.string :nickname, blank: false, default: 'Please enter your nickname'
end
end

def define_store_with_no_attributes(**options)
Expand Down

0 comments on commit fa079ed

Please sign in to comment.