This repository has been archived by the owner on Aug 26, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug 1246459 - Prioritize web by default
- Loading branch information
Showing
12 changed files
with
109 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,35 @@ | ||
from constance.test import override_config | ||
from pyquery import PyQuery as pq | ||
|
||
from kuma.core.tests import KumaTestCase, eq_, ok_ | ||
from kuma.core.urlresolvers import reverse | ||
from kuma.search.models import Filter, FilterGroup | ||
|
||
|
||
class HomeTests(KumaTestCase): | ||
def test_google_analytics(self): | ||
url = reverse('home') | ||
|
||
with override_config(GOOGLE_ANALYTICS_ACCOUNT='0'): | ||
r = self.client.get(url, follow=True) | ||
eq_(200, r.status_code) | ||
ok_('ga(\'create' not in r.content) | ||
response = self.client.get(url, follow=True) | ||
eq_(200, response.status_code) | ||
ok_('ga(\'create' not in response.content) | ||
|
||
with override_config(GOOGLE_ANALYTICS_ACCOUNT='UA-99999999-9'): | ||
r = self.client.get(url, follow=True) | ||
eq_(200, r.status_code) | ||
ok_('ga(\'create' in r.content) | ||
response = self.client.get(url, follow=True) | ||
eq_(200, response.status_code) | ||
ok_('ga(\'create' in response.content) | ||
|
||
def test_default_search_filters(self): | ||
url = reverse('home') | ||
group = FilterGroup.objects.create(name='Topic', slug='topic') | ||
for name in ['CSS', 'HTML', 'JavaScript']: | ||
Filter.objects.create(group=group, name=name, slug=name.lower(), | ||
default=True) | ||
|
||
response = self.client.get(url, follow=True) | ||
page = pq(response.content) | ||
filters = page.find('#home-search-form input[type=hidden]') | ||
filter_vals = [p.val() for p in filters.items()] | ||
eq_(filters.eq(0).attr('name'), 'topic') | ||
eq_(sorted(filter_vals), ['css', 'html', 'javascript']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('search', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='filter', | ||
name='default', | ||
field=models.BooleanField(default=False, help_text=b'Whether this filter is applied in the absence of a user-chosen filter'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters