diff --git a/gemfiles/rails6.gemfile b/gemfiles/rails6.gemfile index 1d64213..81ddd94 100644 --- a/gemfiles/rails6.gemfile +++ b/gemfiles/rails6.gemfile @@ -12,5 +12,5 @@ group :test do gem 'factory_bot' gem 'rspec' gem 'shoulda-matchers' - gem 'sqlite3' + gem 'sqlite3', '~> 1.4' end diff --git a/lib/attach/attachment.rb b/lib/attach/attachment.rb index 9833506..0e93ab2 100644 --- a/lib/attach/attachment.rb +++ b/lib/attach/attachment.rb @@ -25,7 +25,7 @@ class Attachment < ActiveRecord::Base validates :digest, presence: true validates :token, presence: true, uniqueness: { case_sensitive: false } - serialize :custom, type: Hash, default: {} + serialize :custom, coder: YAML, type: Hash, default: {} before_validation :set_token before_validation :set_digest diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e0e6267..97d8b60 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'logger' require 'active_record' require 'shoulda-matchers' require 'factory_bot' @@ -10,8 +11,10 @@ ActiveRecord::Base.include Attach::ModelExtension ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' -ActiveRecord::MigrationContext.new(File.expand_path('../db/migrate', __dir__), - ActiveRecord::SchemaMigration).migrate(nil) +migration_context_args = [File.expand_path('../db/migrate', __dir__)] +# Active Record < 7.1 needs the schema migration class; 7.1+ takes it from the connection +migration_context_args << ActiveRecord::SchemaMigration if ActiveRecord.version < Gem::Version.new('7.1') +ActiveRecord::MigrationContext.new(*migration_context_args).migrate(nil) ActiveRecord::Migration.create_table :users do |t| t.string :name t.datetime :suspended_at