FIX: Heisentest

These tests were failing for the same reason as:
bee68bba2e

Fix was the same.
This commit is contained in:
Robin Ward 2019-01-25 15:24:44 -05:00
parent 84a3da4b18
commit 0f73026c21
1 changed files with 9 additions and 5 deletions

View File

@ -5,6 +5,10 @@ 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)) }
def build_upload
Fabricate.build(:upload, sha1: upload_sha1, id: 1)
end
context 'uploading to s3' do
before(:each) do
SiteSetting.s3_upload_bucket = "some-really-cool-bucket"
@ -20,7 +24,7 @@ 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
upload = Fabricate(:upload, sha1: upload_sha1)
upload = build_upload
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"
)
@ -28,7 +32,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
end
test_multisite_connection('second') do
upload = Fabricate(:upload, sha1: upload_sha1)
upload = build_upload
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"
)
@ -56,7 +60,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)
upload = build_upload
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,7 +77,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)
upload = build_upload
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")
@ -95,7 +99,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)
upload = build_upload
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")