mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
Install ActiveStorage migrations (#1458)
This commit is contained in:
parent
958a9fec66
commit
035822f4ec
2 changed files with 7 additions and 29 deletions
|
@ -26,6 +26,7 @@ module UnitTests
|
|||
def load
|
||||
load_environment
|
||||
|
||||
add_active_storage_migration
|
||||
add_action_text_migration if rails_version >= 6.0
|
||||
|
||||
run_migrations
|
||||
|
@ -150,6 +151,12 @@ end
|
|||
end
|
||||
end
|
||||
|
||||
def add_active_storage_migration
|
||||
fs.within_project do
|
||||
run_command! 'bundle exec rake active_storage:install:migrations'
|
||||
end
|
||||
end
|
||||
|
||||
def add_initializer_for_time_zone_aware_types
|
||||
path = 'config/initializers/configure_time_zone_aware_types.rb'
|
||||
fs.write(path, <<-TEXT)
|
||||
|
|
|
@ -1,35 +1,6 @@
|
|||
require 'unit_spec_helper'
|
||||
|
||||
describe Shoulda::Matchers::ActiveRecord::HaveAttachedMatcher, type: :model do
|
||||
before do
|
||||
create_table :active_storage_blobs do |t|
|
||||
t.string :key, null: false
|
||||
t.string :filename, null: false
|
||||
t.string :content_type
|
||||
t.text :metadata
|
||||
t.bigint :byte_size, null: false
|
||||
t.string :checksum, null: false
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [:key], unique: true
|
||||
end
|
||||
|
||||
create_table :active_storage_attachments do |t|
|
||||
t.string :name, null: false
|
||||
t.references :record, null: false, polymorphic: true, index: false
|
||||
t.references :blob, null: false
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [:record_type, :record_id, :name, :blob_id],
|
||||
name: 'index_active_storage_attachments_uniqueness', unique: true
|
||||
|
||||
# The original rails migration has a foreign key.
|
||||
# Since this messes up the clearing of the database, it's removed here.
|
||||
# t.foreign_key :active_storage_blobs, column: :blob_id
|
||||
end
|
||||
end
|
||||
|
||||
describe 'have_one_attached' do
|
||||
describe '#description' do
|
||||
it 'returns the message with the name of the association' do
|
||||
|
|
Loading…
Reference in a new issue