1
0
Fork 0
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:
Pedro Paiva 2022-09-26 07:22:03 -03:00 committed by GitHub
parent 958a9fec66
commit 035822f4ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 29 deletions

View file

@ -26,6 +26,7 @@ module UnitTests
def load def load
load_environment load_environment
add_active_storage_migration
add_action_text_migration if rails_version >= 6.0 add_action_text_migration if rails_version >= 6.0
run_migrations run_migrations
@ -150,6 +151,12 @@ end
end 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 def add_initializer_for_time_zone_aware_types
path = 'config/initializers/configure_time_zone_aware_types.rb' path = 'config/initializers/configure_time_zone_aware_types.rb'
fs.write(path, <<-TEXT) fs.write(path, <<-TEXT)

View file

@ -1,35 +1,6 @@
require 'unit_spec_helper' require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveAttachedMatcher, type: :model do 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 'have_one_attached' do
describe '#description' do describe '#description' do
it 'returns the message with the name of the association' do it 'returns the message with the name of the association' do