2019-06-25 01:19:58 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
RSpec.describe "Multisite Post", type: :multisite do
|
|
|
|
describe "#each_upload_url" do
|
|
|
|
let(:upload1) { Fabricate(:upload_s3) }
|
|
|
|
let(:upload2) { Fabricate(:upload_s3) }
|
|
|
|
let(:upload3) { Fabricate(:upload_s3) }
|
|
|
|
|
2020-09-14 13:32:25 +02:00
|
|
|
before { setup_s3 }
|
2019-06-25 01:19:58 +05:30
|
|
|
|
2020-09-14 13:32:25 +02:00
|
|
|
it "correctly identifies all upload urls" do
|
2019-06-25 01:19:58 +05:30
|
|
|
upload3.url.sub!(RailsMultisite::ConnectionManagement.current_db, "secondsite")
|
|
|
|
upload3.save!
|
|
|
|
|
|
|
|
urls = []
|
|
|
|
post =
|
|
|
|
Fabricate(
|
|
|
|
:post,
|
|
|
|
raw:
|
|
|
|
"A post with image and link upload.\n\n\n\n<a href='#{upload2.url}'>Link to upload</a>\n",
|
|
|
|
)
|
|
|
|
post.each_upload_url { |src, _, _| urls << src.sub("http:", "") }
|
|
|
|
expect(urls).to eq([upload1.short_path, upload2.url])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|