Skip to content

Commit 4b3a528

Browse files
committed
Merge branch 'master' of github.com:jezdez/django-hosts
2 parents 54253d7 + 39e99c5 commit 4b3a528

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

django_hosts/resolvers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def clear_host_caches():
6767

6868

6969
def setting_changed_receiver(setting, enter, **kwargs):
70-
if not enter and setting in {'ROOT_HOSTCONF', 'DEFAULT_HOST'}:
70+
if setting in {'ROOT_HOSTCONF', 'DEFAULT_HOST'}:
7171
clear_host_caches()
7272

7373

docs/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Changelog
22
=========
33

4-
3.0 (YYYY-MM-DD)
4+
3.0 (2017-11-20)
55
----------------
66

77
- **BACKWARD-INCOMPATIBLE** Dropped support for Django < 1.11.

tests/test_resolvers.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from django.test.utils import override_settings
33
from django.urls import NoReverseMatch
44

5-
from django_hosts.resolvers import (get_hostconf_module, get_host_patterns,
6-
get_host, reverse_host, reverse)
5+
from django_hosts.resolvers import (get_host, get_host_patterns, get_hostconf,
6+
get_hostconf_module, reverse, reverse_host)
77

88
from .base import HostsTestCase
99
from .hosts import simple
@@ -99,3 +99,21 @@ def test_get_host(self):
9999
@override_settings(ROOT_HOSTCONF='tests.hosts.appended')
100100
def test_appended_patterns(self):
101101
self.assertEqual(get_host('special').name, 'special')
102+
103+
104+
@override_settings(
105+
ROOT_HOSTCONF='tests.hosts.simple',
106+
DEFAULT_HOST='www',
107+
)
108+
class SettingChangedClearCacheTests(HostsTestCase):
109+
def test_root_hostconf(self):
110+
self.assertEqual(get_hostconf(), 'tests.hosts.simple')
111+
with self.settings(ROOT_HOSTCONF='tests.hosts.appended'):
112+
self.assertEqual(get_hostconf(), 'tests.hosts.appended')
113+
self.assertEqual(get_hostconf(), 'tests.hosts.simple')
114+
115+
def test_default_host(self):
116+
self.assertEqual(get_host().name, 'www')
117+
with self.settings(DEFAULT_HOST='static'):
118+
self.assertEqual(get_host().name, 'static')
119+
self.assertEqual(get_host().name, 'www')

0 commit comments

Comments
 (0)