diff options
author | George Claghorn <george@basecamp.com> | 2019-05-22 15:07:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 15:07:35 -0400 |
commit | d5a2f7ec148726d7547e367d7a968e3b4be9b509 (patch) | |
tree | 1818959b09d3bdde9b43440fe5ca8fa402984ec3 /activestorage/test/service | |
parent | ff34f78248e367fdc7d59b42b37610427f7339c8 (diff) | |
download | rails-d5a2f7ec148726d7547e367d7a968e3b4be9b509.tar.gz rails-d5a2f7ec148726d7547e367d7a968e3b4be9b509.tar.bz2 rails-d5a2f7ec148726d7547e367d7a968e3b4be9b509.zip |
Mirror direct uploads
Diffstat (limited to 'activestorage/test/service')
-rw-r--r-- | activestorage/test/service/mirror_service_test.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activestorage/test/service/mirror_service_test.rb b/activestorage/test/service/mirror_service_test.rb index 249a5652fb..aa4d610753 100644 --- a/activestorage/test/service/mirror_service_test.rb +++ b/activestorage/test/service/mirror_service_test.rb @@ -53,6 +53,20 @@ class ActiveStorage::Service::MirrorServiceTest < ActiveSupport::TestCase end end + test "mirroring a file from the primary service to secondary services where it doesn't exist" do + key = SecureRandom.base58(24) + data = "Something else entirely!" + checksum = Digest::MD5.base64digest(data) + + @service.primary.upload key, StringIO.new(data), checksum: checksum + @service.mirrors.third.upload key, StringIO.new("Surprise!") + + @service.mirror key, checksum: checksum + assert_equal data, @service.mirrors.first.download(key) + assert_equal data, @service.mirrors.second.download(key) + assert_equal "Surprise!", @service.mirrors.third.download(key) + end + test "URL generation in primary service" do filename = ActiveStorage::Filename.new("test.txt") |