Adds test for editing shelf

This commit is contained in:
Mouse Reeve 2021-01-11 14:23:56 -08:00
parent 7e2460955d
commit 8d88c768cc
2 changed files with 18 additions and 3 deletions

View file

@ -360,6 +360,22 @@ class ViewActions(TestCase):
self.assertEqual(resp.template_name, 'edit_author.html')
def test_edit_shelf(self):
''' set name or privacy on shelf '''
shelf = self.local_user.shelf_set.get(identifier='to-read')
self.assertEqual(shelf.privacy, 'public')
request = self.factory.post(
'', {
'privacy': 'unlisted',
'user': self.local_user.id,
})
request.user = self.local_user
actions.edit_shelf(request, shelf.id)
self.assertEqual(shelf.privacy, 'unlisted')
def test_edit_readthrough(self):
''' adding dates to an ongoing readthrough '''
start = timezone.make_aware(dateutil.parser.parse('2021-01-03'))

View file

@ -355,10 +355,9 @@ def edit_shelf(request, shelf_id):
form = forms.ShelfForm(request.POST, instance=shelf)
if not form.is_valid():
return redirect(request.headers.get('Referer', '/'))
return redirect(shelf.local_path)
shelf = form.save()
return redirect('/user/%s/shelf/%s' % \
(request.user.localname, shelf.identifier))
return redirect(shelf.local_path)
@login_required