Ratings: implement replies by maintainers #181

Merged
Oleg-Komarov merged 7 commits from rating-reply into main 2024-06-11 12:35:03 +02:00
Showing only changes of commit 3ced9fb878 - Show all commits

View File

@ -163,3 +163,18 @@ class AddRatingViewTest(TestCase):
rating = Rating.objects.first() rating = Rating.objects.first()
self.assertEqual(rating.score, 3) self.assertEqual(rating.score, 3)
self.assertEqual(rating.text, text) self.assertEqual(rating.text, text)
def test_reply(self):
version = create_approved_version(ratings=[])
rating = RatingFactory(version=version, text='some text', status=Rating.STATUSES.APPROVED)
random_user = UserFactory()
self.client.force_login(random_user)
response = self.client.post(rating.get_reply_url(), {'text': 'some reply'})
self.assertEqual(response.status_code, 403)
self.client.force_login(version.extension.authors.first())
response = self.client.post(rating.get_reply_url(), {'text': 'some reply'})
self.assertEqual(response.status_code, 302)
rating.refresh_from_db()
self.assertTrue(hasattr(rating, 'ratingreply'))