discourse/spec/multisite/post_spec.rb
David Taylor c9dab6fd08
DEV: Automatically require 'rails_helper' in all specs (#16077)
It's very easy to forget to add `require 'rails_helper'` at the top of every core/plugin spec file, and omissions can cause some very confusing/sporadic errors.

By setting this flag in `.rspec`, we can remove the need for `require 'rails_helper'` entirely.
2022-03-01 17:50:50 +00:00

24 lines
781 B
Ruby

# 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) }
before do
setup_s3
end
it "correctly identifies all upload urls" do
upload3.url.sub!(RailsMultisite::ConnectionManagement.current_db, "secondsite")
upload3.save!
urls = []
post = Fabricate(:post, raw: "A post with image and link upload.\n\n![](#{upload1.short_path})\n\n<a href='#{upload2.url}'>Link to upload</a>\n![](#{upload3.url})")
post.each_upload_url { |src, _, _| urls << src.sub("http:", "") }
expect(urls).to eq([upload1.short_path, upload2.url])
end
end
end