Skip to content

Commit

Permalink
Added test for #1329 and improved changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ddabble committed May 14, 2024
1 parent 437be2b commit 0ee588d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Unreleased
- Added a "Changes" column to ``SimpleHistoryAdmin``'s object history table, listing
the changes between each historical record of the object; see the docs under
"Customizing the History Admin Templates" for overriding its template context (gh-1128)
- Fixed an issue causing m2m historical record to be saved even when
SIMPLE_HISTORY_ENABLED = False in settings.py (gh-1328)
- Fixed the setting ``SIMPLE_HISTORY_ENABLED = False`` not preventing M2M historical
records from being created (gh-1328)

3.5.0 (2024-02-19)
------------------
Expand Down
16 changes: 16 additions & 0 deletions simple_history/tests/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2411,6 +2411,22 @@ def test_skip_history(self):
self.assertEqual(skip_poll.history.all().count(), 2)
self.assertEqual(skip_poll.history.all()[0].places.count(), 2)

@override_settings(SIMPLE_HISTORY_ENABLED=False)
def test_saving_with_disabled_history_doesnt_create_records(self):
# 1 from `setUp()`
self.assertEqual(PollWithManyToMany.history.count(), 1)

poll = PollWithManyToMany.objects.create(
question="skip history?", pub_date=today
)
poll.question = "huh?"
poll.save()
poll.places.add(self.place)

self.assertEqual(poll.history.count(), 0)
# The count should not have changed
self.assertEqual(PollWithManyToMany.history.count(), 1)

def test_diff_against(self):
self.poll.places.add(self.place)
add_record, create_record = self.poll.history.all()
Expand Down

0 comments on commit 0ee588d

Please sign in to comment.