Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Add test for revert

Tom Bowyer2a3e61529792
diff --git a/wger/exercises/tests/test_history.py b/wger/exercises/tests/test_history.py
index 8dcf2ec9e..2096d5a48 100644
--- a/wger/exercises/tests/test_history.py
+++ b/wger/exercises/tests/test_history.py
@@ -65,3 +65,36 @@ class ExerciseHistoryControl(WgerTestCase):
self.assertEqual(StreamVerbs.__members__, response.context['modes'])
self.assertEqual(1, len(response.context['context']))
+
+ def test_admin_revert_view(self):
+ """
+ Test that revert is accessible
+ """
+ self.user_login()
+
+ exercise = Exercise.objects.get(pk=2)
+
+ exercise.save()
+ exercise.name = 'Very cool exercise!'
+ exercise.save()
+
+ exercise = Exercise.objects.get(pk=2)
+
+ most_recent_history = exercise.history.order_by('history_date').last()
+
+ user = User.objects.all().first()
+
+ actstream_action.send(
+ user,
+ verb=StreamVerbs.UPDATED.value,
+ action_object=exercise,
+ data={
+ 'history_id': most_recent_history.history_id,
+ }
+ )
+
+ self.client.get(reverse('exercise:history:history-revert', kwargs={'pk': 2}))
+
+ exercise = Exercise.objects.get(pk=2)
+
+ self.assertNotEqual(exercise.name, 'Very cool exercise!')