parent
45b056b615
commit
0947fa2bad
|
@ -4,7 +4,6 @@ require 'file_store/s3_store'
|
|||
RSpec.describe 'Multisite s3 uploads', type: :multisite do
|
||||
let(:uploaded_file) { file_from_fixtures("smallest.png") }
|
||||
let(:upload_sha1) { Digest::SHA1.hexdigest(File.read(uploaded_file)) }
|
||||
let(:upload) { Fabricate(:upload, sha1: upload_sha1) }
|
||||
|
||||
context 'uploading to s3' do
|
||||
before(:each) do
|
||||
|
@ -21,16 +20,16 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
|
|||
|
||||
it "returns the correct url for default and second multisite db" do
|
||||
test_multisite_connection('default') do
|
||||
test_upload = Fabricate(:upload, sha1: upload_sha1)
|
||||
expect(store.store_upload(uploaded_file, test_upload)).to eq(
|
||||
upload = Fabricate(:upload, sha1: upload_sha1)
|
||||
expect(store.store_upload(uploaded_file, upload)).to eq(
|
||||
"//#{SiteSetting.s3_upload_bucket}.s3.dualstack.us-east-1.amazonaws.com/uploads/default/original/1X/c530c06cf89c410c0355d7852644a73fc3ec8c04.png"
|
||||
)
|
||||
expect(upload.etag).to eq("ETag")
|
||||
end
|
||||
|
||||
test_multisite_connection('second') do
|
||||
test_upload = Fabricate(:upload, sha1: upload_sha1)
|
||||
expect(store.store_upload(uploaded_file, test_upload)).to eq(
|
||||
upload = Fabricate(:upload, sha1: upload_sha1)
|
||||
expect(store.store_upload(uploaded_file, upload)).to eq(
|
||||
"//#{SiteSetting.s3_upload_bucket}.s3.dualstack.us-east-1.amazonaws.com/uploads/second/original/1X/c530c06cf89c410c0355d7852644a73fc3ec8c04.png"
|
||||
)
|
||||
expect(upload.etag).to eq("ETag")
|
||||
|
@ -57,6 +56,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
|
|||
|
||||
it "removes the file from s3 on multisite" do
|
||||
test_multisite_connection('default') do
|
||||
upload = Fabricate(:upload, sha1: upload_sha1)
|
||||
store.expects(:get_depth_for).with(upload.id).returns(0)
|
||||
s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once
|
||||
upload.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/uploads/default/original/1X/#{upload.sha1}.png")
|
||||
|
@ -73,6 +73,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
|
|||
|
||||
it "removes the file from s3 on another multisite db" do
|
||||
test_multisite_connection('second') do
|
||||
upload = Fabricate(:upload, sha1: upload_sha1)
|
||||
store.expects(:get_depth_for).with(upload.id).returns(0)
|
||||
s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once
|
||||
upload.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/uploads/second/original/1X/#{upload.sha1}.png")
|
||||
|
@ -94,6 +95,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
|
|||
|
||||
it "removes the file from s3 on multisite" do
|
||||
test_multisite_connection('default') do
|
||||
upload = Fabricate(:upload, sha1: upload_sha1)
|
||||
store.expects(:get_depth_for).with(upload.id).returns(0)
|
||||
s3_helper.expects(:s3_bucket).returns(s3_bucket).at_least_once
|
||||
upload.update_attributes!(url: "//s3-upload-bucket.s3.dualstack.us-west-1.amazonaws.com/discourse-uploads/uploads/default/original/1X/#{upload.sha1}.png")
|
||||
|
|
Loading…
Reference in New Issue