Skip to content

Commit a6050a6

Browse files
committed
Fix bug with theme url, add test (fix zostera#359)
1 parent 8577582 commit a6050a6

File tree

3 files changed

+31
-24
lines changed

3 files changed

+31
-24
lines changed

bootstrap3/templatetags/bootstrap3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def bootstrap_css():
191191
"""
192192
rendered_urls = [render_link_tag(bootstrap_css_url()), ]
193193
if bootstrap_theme_url():
194-
rendered_urls.append(render_link_tag(bootstrap_css_url()))
194+
rendered_urls.append(render_link_tag(bootstrap_theme_url()))
195195
return mark_safe(''.join([url for url in rendered_urls]))
196196

197197

bootstrap3/tests.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
)
4141

4242

43-
4443
class TestForm(forms.Form):
4544
"""
4645
Form with a variety of widgets to test bootstrap3 rendering.
@@ -207,33 +206,40 @@ def test_bootstrap_javascript_tag(self):
207206
)
208207

209208
def test_bootstrap_css_tag(self):
210-
self.maxDiff = None
211-
res = render_template_with_form('{% bootstrap_css %}')
212-
self.assertEqual(
213-
res.strip(),
214-
'<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">'
209+
res = render_template_with_form('{% bootstrap_css %}').strip()
210+
self.assertIn(
211+
'<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">',
212+
res
213+
)
214+
self.assertIn(
215+
'<link href="//example.com/theme.css" rel="stylesheet">',
216+
res
215217
)
216218

217-
def test_settings_filter(self):
218-
res = render_template_with_form('{{ "required_css_class"|bootstrap_setting }}')
219-
self.assertEqual(res.strip(), 'bootstrap3-req')
220-
res = render_template_with_form('{% if "javascript_in_head"|bootstrap_setting %}head{% else %}body{% endif %}')
221-
self.assertEqual(res.strip(), 'head')
222219

223-
def test_required_class(self):
224-
form = TestForm()
225-
res = render_template_with_form('{% bootstrap_form form %}', {'form': form})
226-
self.assertIn('bootstrap3-req', res)
220+
def test_settings_filter(self):
221+
res = render_template_with_form('{{ "required_css_class"|bootstrap_setting }}')
222+
self.assertEqual(res.strip(), 'bootstrap3-req')
223+
res = render_template_with_form('{% if "javascript_in_head"|bootstrap_setting %}head{% else %}body{% endif %}')
224+
self.assertEqual(res.strip(), 'head')
227225

228-
def test_error_class(self):
229-
form = TestForm({})
230-
res = render_template_with_form('{% bootstrap_form form %}', {'form': form})
231-
self.assertIn('bootstrap3-err', res)
232226

233-
def test_bound_class(self):
234-
form = TestForm({'sender': 'sender'})
235-
res = render_template_with_form('{% bootstrap_form form %}', {'form': form})
236-
self.assertIn('bootstrap3-bound', res)
227+
def test_required_class(self):
228+
form = TestForm()
229+
res = render_template_with_form('{% bootstrap_form form %}', {'form': form})
230+
self.assertIn('bootstrap3-req', res)
231+
232+
233+
def test_error_class(self):
234+
form = TestForm({})
235+
res = render_template_with_form('{% bootstrap_form form %}', {'form': form})
236+
self.assertIn('bootstrap3-err', res)
237+
238+
239+
def test_bound_class(self):
240+
form = TestForm({'sender': 'sender'})
241+
res = render_template_with_form('{% bootstrap_form form %}', {'form': form})
242+
self.assertIn('bootstrap3-bound', res)
237243

238244

239245
class TemplateTest(TestCase):

testsettings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
ROOT_URLCONF = None
4444

4545
BOOTSTRAP3 = {
46+
'theme_url': '//example.com/theme.css',
4647
'javascript_in_head': True,
4748
'required_css_class': 'bootstrap3-req',
4849
'error_css_class': 'bootstrap3-err',

0 commit comments

Comments
 (0)