7

Compare commits

...

5 Commits

Author SHA1 Message Date
d5df6e0e58 Merge branch 'release/0.11.2' 2018-03-08 14:00:38 +02:00
865efd0792 Version 0.11.2 2018-03-08 13:59:23 +02:00
454c936e0f Merge pull request #25 from praekeltfoundation/feature/fix-static-segment-population
Fix off-by-one error in static segment population
2018-03-08 13:24:48 +02:00
74d3123084 Ensure static segments don't have one extra user 2018-03-08 13:14:29 +02:00
9bfd816430 Merge tag '0.11.1' into develop
Populate entirely static segments from registered Users not active Sessions
2018-03-01 16:26:46 +02:00
6 changed files with 23 additions and 5 deletions

View File

@ -1,3 +1,7 @@
0.11.2
==================
- Bugfix: Stop populating static segments when the count is reached
0.11.1
==================
- Populate entirely static segments from registered Users not active Sessions

View File

@ -55,10 +55,10 @@ author = 'Lab Digital BV'
# built documents.
#
# The short X.Y version.
version = '0.11.1'
version = '0.11.2'
# The full version, including alpha/beta/rc tags.
release = '0.11.1'
release = '0.11.2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.

View File

@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.11.1
current_version = 0.11.2
commit = true
tag = true
tag_name = {new_version}

View File

@ -32,7 +32,7 @@ with open('README.rst') as fh:
setup(
name='wagtail-personalisation-molo',
version='0.11.1',
version='0.11.2',
description='A forked version of Wagtail add-on for showing personalized content',
author='Praekelt.org',
author_email='dev@praekeltfoundation.org',

View File

@ -116,7 +116,7 @@ class SegmentAdminForm(WagtailAdminModelForm):
passes = adapter._test_rules(instance.get_rules(), request, instance.match_any)
if passes:
matched_count += 1
if instance.count == 0 or len(users_to_add) <= instance.count:
if instance.count == 0 or len(users_to_add) < instance.count:
if instance.randomise_into_segment():
users_to_add.append(user)
else:

View File

@ -45,6 +45,20 @@ def test_user_added_to_static_segment_at_creation(site, user, mocker):
assert user in instance.static_users.all()
@pytest.mark.django_db
def test_user_not_added_to_full_static_segment_at_creation(site, django_user_model, mocker):
django_user_model.objects.create(username='first')
django_user_model.objects.create(username='second')
segment = SegmentFactory.build(type=Segment.TYPE_STATIC, count=1)
rule = VisitCountRule(counted_page=site.root_page)
form = form_with_data(segment, rule)
mocker.patch('wagtail_personalisation.rules.VisitCountRule.test_user',
side_effect=[True, True])
instance = form.save()
assert len(instance.static_users.all()) == 1
@pytest.mark.django_db
def test_anonymous_user_not_added_to_static_segment_at_creation(site, client, mocker):
session = client.session