2021-07-07 12:57:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe InlineUploads, type: :multisite do
|
|
|
|
before { set_cdn_url "https://awesome.com" }
|
|
|
|
|
|
|
|
describe ".process" do
|
|
|
|
describe "s3 uploads" do
|
|
|
|
let(:upload) { Fabricate(:upload_s3) }
|
|
|
|
let(:upload2) { Fabricate(:upload_s3) }
|
|
|
|
let(:upload3) { Fabricate(:upload) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
upload3
|
|
|
|
setup_s3
|
|
|
|
SiteSetting.s3_cdn_url = "https://s3.cdn.com"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should correct image URLs in multisite" do
|
|
|
|
md = <<~MD
|
|
|
|
https:#{upload2.url} https:#{upload2.url}
|
2023-12-06 17:25:00 -05:00
|
|
|
#{URI.join(SiteSetting.s3_cdn_url, URI.parse(upload2.url).path)}
|
2021-07-07 12:57:42 -04:00
|
|
|
|
|
|
|
<img src="#{upload.url}" alt="some image">
|
2023-12-06 17:25:00 -05:00
|
|
|
<img src="#{URI.join(SiteSetting.s3_cdn_url, URI.parse(upload2.url).path)}" alt="some image">
|
2021-07-07 12:57:42 -04:00
|
|
|
<img src="#{upload3.url}">
|
|
|
|
MD
|
|
|
|
|
|
|
|
expect(InlineUploads.process(md)).to eq(<<~MD)
|
|
|
|
#{Discourse.base_url}#{upload2.short_path} #{Discourse.base_url}#{upload2.short_path}
|
|
|
|
#{Discourse.base_url}#{upload2.short_path}
|
|
|
|
|
2022-03-29 05:55:10 -04:00
|
|
|
<img src="#{upload.short_url}" alt="some image">
|
|
|
|
<img src="#{upload2.short_url}" alt="some image">
|
|
|
|
<img src="#{upload3.short_url}">
|
2021-07-07 12:57:42 -04:00
|
|
|
MD
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|