Skip to content
Snippets Groups Projects
Commit c36b1ff0 authored by Martin Burchell's avatar Martin Burchell
Browse files

Fixed item last_modified to update on term delete

parent 7acdead7
Branches
No related tags found
1 merge request!7Data Layer updates a "last edit date" field on the Item
......@@ -55,7 +55,7 @@ Item = Message
@receiver(models.signals.m2m_changed, sender=Item.terms.through,
dispatch_uid="data_layer.models.terms_signal_handler")
def terms_signal_handler(sender, **kwargs):
if kwargs.get('action') != 'post_add':
if kwargs.get('action') not in ('post_add', 'post_remove'):
return
if kwargs.get('reverse'):
......
......@@ -66,6 +66,18 @@ def test_last_modified_date_updates_on_item_category_add(
assert num_updates(orig_last_modified, last_modified(item)) == 1
@pytest.mark.django_db
def test_last_modified_date_updates_on_item_category_delete(
item, mock_time_now):
with patch('django.utils.timezone.now', new=mock_time_now):
term = TermFactory()
item.terms.add(term)
orig_last_modified = last_modified(item)
item.terms.remove(term)
assert num_updates(orig_last_modified, last_modified(item)) == 1
@pytest.mark.django_db
def test_last_modified_date_updates_on_category_item_add(
item, mock_time_now):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment