mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 08:43:25 +08:00
FIX: inconsistency in S3 inventory config (#11112)
Ensures it matches S3 inventory config generation in our hosting.
This commit is contained in:
parent
2686d14b9a
commit
9f6c4ad71a
|
@ -270,7 +270,7 @@ class S3Inventory
|
|||
|
||||
def inventory_configuration
|
||||
filter_prefix = type
|
||||
filter_prefix = File.join(bucket_folder_path, filter_prefix) if bucket_folder_path.present?
|
||||
filter_prefix = bucket_folder_path if bucket_folder_path.present?
|
||||
|
||||
{
|
||||
destination: {
|
||||
|
|
|
@ -187,4 +187,25 @@ describe "S3Inventory" do
|
|||
expect(db2.lines.count).to eq(1)
|
||||
files.values.each { |f| f.close; f.unlink }
|
||||
end
|
||||
|
||||
context "s3 inventory configuration" do
|
||||
let(:bucket_name) { "s3-upload-bucket" }
|
||||
let(:subfolder_path) { "subfolder" }
|
||||
before do
|
||||
SiteSetting.s3_upload_bucket = "#{bucket_name}/#{subfolder_path}"
|
||||
end
|
||||
|
||||
it "is formatted correctly for subfolders" do
|
||||
s3_helper = S3Helper.new(SiteSetting.Upload.s3_upload_bucket.downcase, "", client: client)
|
||||
config = S3Inventory.new(s3_helper, :upload).send(:inventory_configuration)
|
||||
|
||||
expect(config[:destination][:s3_bucket_destination][:bucket]).to eq("arn:aws:s3:::#{bucket_name}")
|
||||
expect(config[:destination][:s3_bucket_destination][:prefix]).to eq("#{subfolder_path}/inventory/1")
|
||||
expect(config[:id]).to eq("#{subfolder_path}-original")
|
||||
expect(config[:schedule][:frequency]).to eq("Daily")
|
||||
expect(config[:included_object_versions]).to eq("Current")
|
||||
expect(config[:optional_fields]).to eq(["ETag"])
|
||||
expect(config[:filter][:prefix]).to eq(subfolder_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user