mirror of
https://github.com/sissbruecker/linkding
synced 2025-02-18 13:18:28 +00:00
* Make shared view public, add user profile fallback * Allow unauthenticated access to shared bookmarks API * Link shared bookmarks in unauthenticated layout * Add public sharing setting * Only show shared bookmarks link if there are publicly shared bookmarks * Disable public sharing if sharing is disabled * Show specific helper text when public sharing is enabled * Fix tests * Add more tests * Improve setting description
26 lines
1,000 B
Python
26 lines
1,000 B
Python
from django.test import TestCase
|
|
from django.urls import reverse
|
|
|
|
from bookmarks.tests.helpers import BookmarkFactoryMixin
|
|
|
|
|
|
class AnonymousViewTestCase(TestCase, BookmarkFactoryMixin):
|
|
def assertSharedBookmarksLinkCount(self, response, count):
|
|
url = reverse('bookmarks:shared')
|
|
self.assertContains(response, f'<a href="{url}" class="btn btn-link">Shared bookmarks</a>',
|
|
count=count)
|
|
|
|
def test_publicly_shared_bookmarks_link(self):
|
|
# should not render link if no public shares exist
|
|
user = self.setup_user(enable_sharing=True)
|
|
self.setup_bookmark(user=user, shared=True)
|
|
|
|
response = self.client.get(reverse('login'))
|
|
self.assertSharedBookmarksLinkCount(response, 0)
|
|
|
|
# should render link if public shares exist
|
|
user.profile.enable_public_sharing = True
|
|
user.profile.save()
|
|
|
|
response = self.client.get(reverse('login'))
|
|
self.assertSharedBookmarksLinkCount(response, 1)
|