Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gemfiles/rails6.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ group :test do
gem 'factory_bot'
gem 'rspec'
gem 'shoulda-matchers'
gem 'sqlite3'
gem 'sqlite3', '~> 1.4'
end
2 changes: 1 addition & 1 deletion lib/attach/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'logger'
require 'active_record'
require 'shoulda-matchers'
require 'factory_bot'
Expand All @@ -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
Expand Down
Loading