mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 11:13:22 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
44 lines
1.3 KiB
Ruby
44 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'global_path'
|
|
|
|
class GlobalPathInstance
|
|
extend GlobalPath
|
|
end
|
|
|
|
RSpec.describe GlobalPath do
|
|
|
|
context 'cdn_relative_path' do
|
|
def cdn_relative_path(p)
|
|
GlobalPathInstance.cdn_relative_path(p)
|
|
end
|
|
|
|
it "just returns path for no cdn" do
|
|
expect(cdn_relative_path("/test")).to eq("/test")
|
|
end
|
|
|
|
it "returns path when a cdn is defined with a path" do
|
|
GlobalSetting.expects(:cdn_url).returns("//something.com/foo")
|
|
expect(cdn_relative_path("/test")).to eq("/foo/test")
|
|
end
|
|
|
|
it "returns path when a cdn is defined with a path" do
|
|
GlobalSetting.expects(:cdn_url).returns("https://something.com:221/foo")
|
|
expect(cdn_relative_path("/test")).to eq("/foo/test")
|
|
end
|
|
end
|
|
|
|
describe '#upload_cdn_path' do
|
|
it 'generates correctly when S3 bucket has a folder' do
|
|
global_setting :s3_access_key_id, 's3_access_key_id'
|
|
global_setting :s3_secret_access_key, 's3_secret_access_key'
|
|
global_setting :s3_bucket, 'file-uploads/folder'
|
|
global_setting :s3_region, 'us-west-2'
|
|
global_setting :s3_cdn_url, 'https://cdn-aws.com/folder'
|
|
|
|
expect(GlobalPathInstance.upload_cdn_path("#{Discourse.store.absolute_base_url}/folder/upload.jpg"))
|
|
.to eq("https://cdn-aws.com/folder/upload.jpg")
|
|
end
|
|
end
|
|
end
|