Merge pull request #37448 from gmcgibbon/fix_flaky_activestorage_tests

Fix flaky activestorage tests
This commit is contained in:
Gannon McGibbon 2019-10-12 21:39:00 -04:00 committed by GitHub
commit d1b39eaf12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 4 deletions

View File

@ -1,7 +1,5 @@
# frozen_string_literal: true
require "active_storage/downloader"
# A blob is a record that contains the metadata about a file and a key for where that file resides on the service.
# Blobs can be created in two ways:
#

View File

@ -1,6 +1,7 @@
# frozen_string_literal: true
require "active_storage/log_subscriber"
require "active_storage/downloader"
require "action_dispatch"
require "action_dispatch/http/content_disposition"

View File

@ -10,7 +10,9 @@ class ActiveStorage::ManyAttachedTest < ActiveSupport::TestCase
@user = User.create!(name: "Josh")
end
teardown { ActiveStorage::Blob.all.each(&:delete) }
teardown do
ActiveStorage::Blob.all.each(&:delete)
end
test "attaching existing blobs to an existing record" do
@user.highlights.attach create_blob(filename: "funky.jpg"), create_blob(filename: "town.jpg")

View File

@ -12,7 +12,9 @@ class ActiveStorage::OneAttachedTest < ActiveSupport::TestCase
@user = User.create!(name: "Josh")
end
teardown { ActiveStorage::Blob.all.each(&:delete) }
teardown do
ActiveStorage::Blob.all.each(&:delete)
end
test "attaching an existing blob to an existing record" do
@user.avatar.attach create_blob(filename: "funky.jpg")

View File

@ -52,6 +52,8 @@ ActiveStorage.verifier = ActiveSupport::MessageVerifier.new("Testing")
class ActiveSupport::TestCase
self.file_fixture_path = File.expand_path("fixtures/files", __dir__)
include ActiveRecord::TestFixtures
setup do
ActiveStorage::Current.host = "https://example.com"
end