From 8d1b0224acba982d2a654edd4e68cfe9ea2a3cff Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 29 May 2019 18:53:31 +0800 Subject: [PATCH] Fix the build a3938f98f8b575675fc9b541725aa224fcddf682. --- spec/components/file_store/s3_store_spec.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/spec/components/file_store/s3_store_spec.rb b/spec/components/file_store/s3_store_spec.rb index 4474613c50d..65d132b3b7d 100644 --- a/spec/components/file_store/s3_store_spec.rb +++ b/spec/components/file_store/s3_store_spec.rb @@ -303,12 +303,20 @@ describe FileStore::S3Store do end describe ".path_for" do - it "correctly falls back to local" do - local_upload = Fabricate(:upload) - s3_upload = Fabricate(:upload_s3) + def assert_path(path, expected) + upload = Upload.new(url: path) - expect(Discourse.store.path_for(local_upload)).to eq(local_upload.url) - expect(Discourse.store.path_for(s3_upload)).to eq(s3_upload.url) + path = store.path_for(upload) + expected = FileStore::LocalStore.new.path_for(upload) if expected + + expect(path).to eq(expected) + end + + it "correctly falls back to local" do + assert_path("/hello", "/hello") + assert_path("//hello", nil) + assert_path("http://hello", nil) + assert_path("https://hello", nil) end end