Skip to content

Commit

Permalink
fixes #1 by adding a test for correct email notification
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizkas0 committed Mar 5, 2021
1 parent 9a20178 commit 4d94322
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions wger/exercises/tests/test_exercise.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,14 @@ def test_add_exercise_name_too_similar_fail(self):
# Exercise was not added
self.assertEqual(count_before, count_after)

def add_exercise_success(self, admin=False):
def add_exercise_success(self, admin=False, name_original=random_string()):
"""
Tests adding/editing an exercise with a user with enough rights to do this
"""

# Add an exercise
count_before = Exercise.objects.count()
description = 'a nice, long and accurate description for the exercise'
name_original = random_string()
response = self.client.post(reverse('exercise:exercise:add'),
{'name_original': name_original,
'license': 1,
Expand Down Expand Up @@ -385,6 +384,15 @@ def test_add_exercise_success(self):
self.user_login('admin')
self.add_exercise_success(admin=True)

def test_notification_email_contains_name(self):
"""
Tests adding/editing an exercise with a user with enough rights to do this
"""
exercise_name = "Kalle"
self.user_login('test')
self.add_exercise_success(name_original=exercise_name)
self.assertEquals(mail.outbox[0].body, "The user test submitted a new exercise \"" + exercise_name + "\".")

def test_add_exercise_user_no_rights(self):
"""
Tests adding an exercise with a user without enough rights to do this
Expand Down

0 comments on commit 4d94322

Please sign in to comment.