Skip to content

A platform for community discussion. Free, open, simple.

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

Penar Musaraj8546c2084acc
diff --git a/lib/discourse.rb b/lib/discourse.rb
index 1773d4e3054..68c2e6f2104 100644
--- a/lib/discourse.rb
+++ b/lib/discourse.rb
@@ -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
diff --git a/lib/middleware/enforce_hostname.rb b/lib/middleware/enforce_hostname.rb
index 486753c7d7f..44ac8d7d4a1 100644
--- a/lib/middleware/enforce_hostname.rb
+++ b/lib/middleware/enforce_hostname.rb
@@ -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
diff --git a/spec/support/system_helpers.rb b/spec/support/system_helpers.rb
index 6677d1a168b..ee9faba604b 100644
--- a/spec/support/system_helpers.rb
+++ b/spec/support/system_helpers.rb
@@ -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