Add continuous collection reading view
This commit is contained in:
+22
-6
@@ -159,20 +159,22 @@ class CollectionTests(TestCase):
|
||||
collection = Collection.objects.get()
|
||||
self.assertRedirects(response, collection.get_absolute_url())
|
||||
note = Item.objects.create(owner=self.user, kind=Item.Kind.NOTE, content='Introduction')
|
||||
response = self.client.post(collection.get_absolute_url(), {'action': 'add', 'item_id': note.id})
|
||||
self.assertRedirects(response, collection.get_absolute_url())
|
||||
manage_url = reverse('collection_manage', args=[collection.id])
|
||||
response = self.client.post(manage_url, {'action': 'add', 'item_id': note.id})
|
||||
self.assertRedirects(response, manage_url)
|
||||
self.assertTrue(CollectionSection.objects.filter(collection=collection, item=note).exists())
|
||||
|
||||
def test_public_collection_asks_before_copying_private_note(self):
|
||||
collection = Collection.objects.create(owner=self.user, title='Public guide', visibility=Item.Visibility.PUBLIC)
|
||||
note = Item.objects.create(owner=self.user, kind=Item.Kind.NOTE, content='Private section')
|
||||
response = self.client.post(collection.get_absolute_url(), {'action': 'add', 'item_id': note.id})
|
||||
manage_url = reverse('collection_manage', args=[collection.id])
|
||||
response = self.client.post(manage_url, {'action': 'add', 'item_id': note.id})
|
||||
self.assertContains(response, 'name="mode" value="copy"')
|
||||
|
||||
response = self.client.post(collection.get_absolute_url(), {
|
||||
response = self.client.post(manage_url, {
|
||||
'action': 'confirm_add', 'item_id': note.id, 'mode': 'copy',
|
||||
})
|
||||
self.assertRedirects(response, collection.get_absolute_url())
|
||||
self.assertRedirects(response, manage_url)
|
||||
copied = collection.sections.get().item
|
||||
self.assertNotEqual(copied.id, note.id)
|
||||
self.assertEqual(copied.visibility, Item.Visibility.PUBLIC)
|
||||
@@ -199,10 +201,24 @@ class CollectionTests(TestCase):
|
||||
self.assertEqual(collection.team, team)
|
||||
self.assertEqual(collection.visibility, Item.Visibility.TEAM)
|
||||
|
||||
def test_collection_opens_as_continuous_reading_view(self):
|
||||
collection = Collection.objects.create(owner=self.user, title='Reading view')
|
||||
first = Item.objects.create(owner=self.user, kind=Item.Kind.NOTE, content='First paragraph')
|
||||
second = Item.objects.create(owner=self.user, kind=Item.Kind.NOTE, content='Second paragraph')
|
||||
CollectionSection.objects.create(collection=collection, item=first, title='First', position=0)
|
||||
CollectionSection.objects.create(collection=collection, item=second, position=1)
|
||||
response = self.client.get(collection.get_absolute_url())
|
||||
self.assertContains(response, 'collection-flow')
|
||||
self.assertContains(response, reverse('collection_manage', args=[collection.id]))
|
||||
self.assertNotContains(response, 'Add existing note')
|
||||
self.assertNotContains(response, 'section_id')
|
||||
|
||||
def test_public_collection_is_visible_without_login(self):
|
||||
collection = Collection.objects.create(owner=self.user, title='Public', visibility=Item.Visibility.PUBLIC)
|
||||
self.client.logout()
|
||||
self.assertEqual(self.client.get(collection.get_absolute_url()).status_code, 200)
|
||||
response = self.client.get(collection.get_absolute_url())
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertNotContains(response, reverse('collection_manage', args=[collection.id]))
|
||||
|
||||
def test_collection_tag_is_not_removed_as_unused(self):
|
||||
tag = Tag.objects.create(name='documentation')
|
||||
|
||||
Reference in New Issue
Block a user