forked from mirrors/bookwyrm
Adds test for editing shelf
This commit is contained in:
parent
7e2460955d
commit
8d88c768cc
2 changed files with 18 additions and 3 deletions
|
@ -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'))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue