DEV: Load SVG sprites during system spec runs (#19497)

Co-authored-by: David Taylor <david@taylorhq.com>
This commit is contained in:
Penar Musaraj 2022-12-22 08:13:43 -05:00 committed by GitHub
parent 263cd02a27
commit 8546c2084a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -498,16 +498,20 @@ module Discourse
SiteSetting.force_https? ? "https" : "http"
end
def self.base_url_no_prefix
def self.current_hostname_with_port
default_port = SiteSetting.force_https? ? 443 : 80
url = +"#{base_protocol}://#{current_hostname}"
url << ":#{SiteSetting.port}" if SiteSetting.port.to_i > 0 && SiteSetting.port.to_i != default_port
result = +"#{current_hostname}"
result << ":#{SiteSetting.port}" if SiteSetting.port.to_i > 0 && SiteSetting.port.to_i != default_port
if Rails.env.development? && SiteSetting.port.blank?
url << ":#{ENV["UNICORN_PORT"] || 3000}"
result << ":#{ENV["UNICORN_PORT"] || 3000}"
end
url
result
end
def self.base_url_no_prefix
"#{base_protocol}://#{current_hostname_with_port}"
end
def self.base_url

View File

@ -18,7 +18,7 @@ module Middleware
requested_hostname = env[Rack::HTTP_HOST]
env[Discourse::REQUESTED_HOSTNAME] = requested_hostname
env[Rack::HTTP_HOST] = allowed_hostnames.find { |h| h == requested_hostname } || Discourse.current_hostname
env[Rack::HTTP_HOST] = allowed_hostnames.find { |h| h == requested_hostname } || Discourse.current_hostname_with_port
@app.call(env)
end

View File

@ -22,7 +22,8 @@ module SystemHelpers
def setup_system_test
SiteSetting.login_required = false
SiteSetting.content_security_policy = false
SiteSetting.force_hostname = "#{Capybara.server_host}:#{Capybara.server_port}"
SiteSetting.force_hostname = Capybara.server_host
SiteSetting.port = Capybara.server_port
SiteSetting.external_system_avatars_enabled = false
end