Skip to content

Commit 61e0f92

Browse files
committed
Test against configured host rather than request host
1 parent 4058426 commit 61e0f92

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

app/controllers/callbacks_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def handle_callback(provider, config)
4545
private
4646

4747
def redirect_to_space(path, space)
48-
if space && space.is_subdomain?(request.domain)
48+
if space&.is_subdomain?
4949
port_part = ''
5050
port_part = ":#{request.port}" if (request.protocol == "http://" && request.port != 80) ||
5151
(request.protocol == "https://" && request.port != 443)

app/models/space.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def enabled_features
6565
(FEATURES - disabled_features)
6666
end
6767

68-
def is_subdomain?(domain)
68+
def is_subdomain?(domain = TeSS::Config.base_uri.domain)
6969
(host == domain || host.ends_with?(".#{domain}"))
7070
end
7171

test/models/space_test.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ class SpaceTest < ActiveSupport::TestCase
129129
assert_equal [], @space.disabled_features
130130
end
131131

132-
test 'check subdomain of' do
132+
test 'is_subdomain?' do
133133
assert @space.is_subdomain?('mytess.training')
134134
refute @space.is_subdomain?('amytess.training')
135135
refute @space.is_subdomain?('mytess.com')
136136
refute @space.is_subdomain?('mytess.training.com')
137137
refute @space.is_subdomain?('space.mytess.training')
138+
refute @space.is_subdomain?
139+
assert Space.new(host: 'test.example.com').is_subdomain?
138140
end
139141
end

0 commit comments

Comments
 (0)