parent
1d76b7b7b5
commit
45aebd00a5
|
@ -4,6 +4,8 @@ require "s3_helper"
|
|||
require "rails_helper"
|
||||
|
||||
describe "S3Helper" do
|
||||
let(:client) { Aws::S3::Client.new(stub_responses: true) }
|
||||
|
||||
before(:each) do
|
||||
SiteSetting.enable_s3_uploads = true
|
||||
SiteSetting.s3_access_key_id = "abc"
|
||||
|
@ -70,23 +72,19 @@ describe "S3Helper" do
|
|||
'some/bucket' => 'bucket/testing',
|
||||
'some' => 'testing'
|
||||
}.each do |bucket_name, prefix|
|
||||
s3_helper = S3Helper.new(bucket_name)
|
||||
bucket = stub('s3_bucket')
|
||||
s3_helper.expects(:s3_bucket).returns(bucket)
|
||||
bucket.expects(:objects).with(prefix: prefix)
|
||||
s3_helper = S3Helper.new(bucket_name, "", client: client)
|
||||
Aws::S3::Bucket.any_instance.expects(:objects).with(prefix: prefix)
|
||||
s3_helper.list('testing')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it "should prefix bucket folder path only if not exists" do
|
||||
s3_helper = S3Helper.new('bucket/folder_path')
|
||||
bucket = stub('s3_bucket')
|
||||
s3_helper = S3Helper.new('bucket/folder_path', "", client: client)
|
||||
|
||||
s3_helper.expects(:s3_bucket).returns(bucket).twice
|
||||
bucket.expects(:object).with("folder_path/original/1X/def.xyz").twice
|
||||
object1 = s3_helper.object("original/1X/def.xyz")
|
||||
object2 = s3_helper.object("folder_path/original/1X/def.xyz")
|
||||
|
||||
s3_helper.object("original/1X/def.xyz")
|
||||
s3_helper.object("folder_path/original/1X/def.xyz")
|
||||
expect(object1.key).to eq(object2.key)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue