DEV: Use the `type: :multisite` spec setting (#9245)

Fixes recent spec flakiness.

Also includes:
DEV: Prevent accidental exit from specs
This commit is contained in:
Jarek Radosz 2020-03-20 16:18:34 +01:00 committed by GitHub
parent 1859e6b7ca
commit 20f3be1e9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 33 deletions

View File

@ -401,10 +401,7 @@ describe UploadsController do
expect(response.code).to eq("403")
end
context "when running on a multisite connection" do
before do
Rails.configuration.multisite = true
end
context "when running on a multisite connection", type: :multisite do
it "redirects to the signed_url_for_path with the multisite DB name in the url" do
freeze_time
get upload.short_path

View File

@ -691,30 +691,24 @@ RSpec.describe InlineUploads do
MD
end
it "should correct image URLs in multisite" do
begin
Rails.configuration.multisite = true
it "should correct image URLs in multisite", type: :multisite do
md = <<~MD
https:#{upload2.url} https:#{upload2.url}
#{URI.join(SiteSetting.s3_cdn_url, URI.parse(upload2.url).path).to_s}
md = <<~MD
https:#{upload2.url} https:#{upload2.url}
#{URI.join(SiteSetting.s3_cdn_url, URI.parse(upload2.url).path).to_s}
<img src="#{upload.url}" alt="some image">
<img src="#{URI.join(SiteSetting.s3_cdn_url, URI.parse(upload2.url).path).to_s}" alt="some image">
<img src="#{upload3.url}">
MD
<img src="#{upload.url}" alt="some image">
<img src="#{URI.join(SiteSetting.s3_cdn_url, URI.parse(upload2.url).path).to_s}" alt="some image">
<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}
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}
![some image](#{upload.short_url})
![some image](#{upload2.short_url})
![](#{upload3.short_url})
MD
ensure
Rails.configuration.multisite = false
end
![some image](#{upload.short_url})
![some image](#{upload2.short_url})
![](#{upload3.short_url})
MD
end
end
end

View File

@ -2,19 +2,13 @@
require 'rails_helper'
RSpec.describe "Redis rake tasks" do
RSpec.describe "Redis rake tasks", type: :multisite do
let(:redis) { Discourse.redis.without_namespace }
before do
@multisite = Rails.configuration.multisite
Rails.configuration.multisite = true
Discourse::Application.load_tasks
end
after do
Rails.configuration.multisite = @multisite
end
describe 'clean up' do
it 'should clean up orphan Redis keys' do
active_keys = [

View File

@ -43,7 +43,7 @@ RSpec.describe "tasks/uploads" do
context "when the store is internal" do
it "does nothing; this is for external store only" do
Upload.expects(:transaction).never
invoke_task
expect { invoke_task }.to raise_error(SystemExit)
end
end