FIX: All multisite upload paths should start with /uploads/default/.. (#6707)

This commit is contained in:
Rishabh 2018-12-03 09:34:14 +05:30 committed by Guo Xiang Tan
parent 6121d11187
commit 503ae1829f
3 changed files with 8 additions and 4 deletions

View File

@ -42,7 +42,7 @@ module FileStore
options[:content_disposition] = "attachment; filename=\"#{filename}\"" unless FileHelper.is_supported_image?(filename)
# if this fails, it will throw an exception
path.prepend(File.join(upload_path, "/")) if RailsMultisite::ConnectionManagement.current_db != "default"
path.prepend(File.join(upload_path, "/")) if Rails.configuration.multisite
path = @s3_helper.upload(file, path, options)
# return the upload url

View File

@ -27,9 +27,11 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
describe "#store_upload" do
it "returns the correct url for default and second multisite db" do
expect(store.store_upload(uploaded_file, upload)).to eq(
"//#{SiteSetting.s3_upload_bucket}.s3.dualstack.us-east-1.amazonaws.com/original/1X/c530c06cf89c410c0355d7852644a73fc3ec8c04.png"
)
conn.with_connection('default') do
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"
)
end
conn.with_connection('second') do
expect(store.store_upload(uploaded_file, upload)).to eq(

View File

@ -180,11 +180,13 @@ RSpec.configure do |config|
end
config.before(:each, type: :multisite) do
Rails.configuration.multisite = true
RailsMultisite::ConnectionManagement.config_filename =
"spec/fixtures/multisite/two_dbs.yml"
end
config.after(:each, type: :multisite) do
Rails.configuration.multisite = false
RailsMultisite::ConnectionManagement.clear_settings!
ActiveRecord::Base.clear_active_connections!
ActiveRecord::Base.establish_connection