list sharing implemented w. passing UTs & FTs; changes to apps.dashboard.urls, .models, .views & .tests.test_views to accomodate; functional_tests.test_sharing also ensures sharing visible in UX; templates/apps/dashboard/list.html & /my_lists.html updated with django templating & for loops
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import lxml.html
|
||||
from unittest import skip
|
||||
from django.test import TestCase
|
||||
from django.utils import html
|
||||
from unittest import skip
|
||||
|
||||
from ..forms import (
|
||||
DUPLICATE_ITEM_ERROR,
|
||||
EMPTY_ITEM_ERROR,
|
||||
@@ -9,6 +10,7 @@ from ..forms import (
|
||||
from ..models import Item, List
|
||||
from apps.lyric.models import User
|
||||
|
||||
|
||||
class HomePageTest(TestCase):
|
||||
def test_uses_home_template(self):
|
||||
response = self.client.get('/')
|
||||
@@ -180,3 +182,22 @@ class MyListsTest(TestCase):
|
||||
response = self.client.get(f"/apps/dashboard/users/{user1.id}/")
|
||||
# assert 403
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
class ShareListTest(TestCase):
|
||||
def test_post_to_share_list_url_redirects_to_list(self):
|
||||
our_list = List.objects.create()
|
||||
alice = User.objects.create(email="alice@example.com")
|
||||
response = self.client.post(
|
||||
f"/apps/dashboard/{our_list.id}/share_list",
|
||||
data={"recipient": "alice@example.com"},
|
||||
)
|
||||
self.assertRedirects(response, f"/apps/dashboard/{our_list.id}/")
|
||||
|
||||
def test_post_with_email_adds_user_to_shared_with(self):
|
||||
our_list = List.objects.create()
|
||||
alice = User.objects.create(email="alice@example.com")
|
||||
self.client.post(
|
||||
f"/apps/dashboard/{our_list.id}/share_list",
|
||||
data={"recipient": "alice@example.com"},
|
||||
)
|
||||
self.assertIn(alice, our_list.shared_with.all())
|
||||
|
||||
Reference in New Issue
Block a user