found-n-replaced all instances of name='item_text' w. ='text'
This commit is contained in:
@@ -14,29 +14,29 @@ class HomePageTest(TestCase):
|
|||||||
[form] = parsed.cssselect('form[method=POST]')
|
[form] = parsed.cssselect('form[method=POST]')
|
||||||
self.assertEqual(form.get('action'), '/apps/dashboard/newlist')
|
self.assertEqual(form.get('action'), '/apps/dashboard/newlist')
|
||||||
inputs = form.cssselect('input')
|
inputs = form.cssselect('input')
|
||||||
self.assertIn('item_text', [input.get('name') for input in inputs])
|
self.assertIn('text', [input.get('name') for input in inputs])
|
||||||
|
|
||||||
class NewListTest(TestCase):
|
class NewListTest(TestCase):
|
||||||
def test_can_save_a_POST_request(self):
|
def test_can_save_a_POST_request(self):
|
||||||
self. client.post('/apps/dashboard/newlist', data={'item_text': 'A new list item'})
|
self. client.post('/apps/dashboard/newlist', data={'text': 'A new list item'})
|
||||||
self.assertEqual(Item.objects.count(), 1)
|
self.assertEqual(Item.objects.count(), 1)
|
||||||
new_item = Item.objects.get()
|
new_item = Item.objects.get()
|
||||||
self.assertEqual(new_item.text, 'A new list item')
|
self.assertEqual(new_item.text, 'A new list item')
|
||||||
|
|
||||||
def test_redirects_after_POST(self):
|
def test_redirects_after_POST(self):
|
||||||
response = self.client.post('/apps/dashboard/newlist', data={'item_text': 'A new list item'})
|
response = self.client.post('/apps/dashboard/newlist', data={'text': 'A new list item'})
|
||||||
new_list = List.objects.get()
|
new_list = List.objects.get()
|
||||||
self.assertRedirects(response, f'/apps/dashboard/{new_list.id}/')
|
self.assertRedirects(response, f'/apps/dashboard/{new_list.id}/')
|
||||||
|
|
||||||
def test_validation_errors_are_sent_back_to_home_page_template(self):
|
def test_validation_errors_are_sent_back_to_home_page_template(self):
|
||||||
response = self.client.post("/apps/dashboard/newlist", data={"item_text": ""})
|
response = self.client.post("/apps/dashboard/newlist", data={"text": ""})
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertTemplateUsed(response, "apps/dashboard/home.html")
|
self.assertTemplateUsed(response, "apps/dashboard/home.html")
|
||||||
expected_error = html.escape("You can't have an empty list item")
|
expected_error = html.escape("You can't have an empty list item")
|
||||||
self.assertContains(response, expected_error)
|
self.assertContains(response, expected_error)
|
||||||
|
|
||||||
def test_invalid_list_items_never_save(self):
|
def test_invalid_list_items_never_save(self):
|
||||||
self.client.post("/apps/dashboard/newlist", data={"item_text": ""})
|
self.client.post("/apps/dashboard/newlist", data={"text": ""})
|
||||||
self.assertEqual(List.objects.count(), 0)
|
self.assertEqual(List.objects.count(), 0)
|
||||||
self.assertEqual(Item.objects.count(), 0)
|
self.assertEqual(Item.objects.count(), 0)
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class DashViewTest(TestCase):
|
|||||||
[form] = parsed.cssselect('form[method=POST]')
|
[form] = parsed.cssselect('form[method=POST]')
|
||||||
self.assertEqual(form.get('action'), f"/apps/dashboard/{mylist.id}/")
|
self.assertEqual(form.get('action'), f"/apps/dashboard/{mylist.id}/")
|
||||||
inputs = form.cssselect('input')
|
inputs = form.cssselect('input')
|
||||||
self.assertIn('item_text', [input.get('name') for input in inputs])
|
self.assertIn('text', [input.get('name') for input in inputs])
|
||||||
|
|
||||||
def test_displays_only_items_for_that_list(self):
|
def test_displays_only_items_for_that_list(self):
|
||||||
# Given/Arrange
|
# Given/Arrange
|
||||||
@@ -75,7 +75,7 @@ class DashViewTest(TestCase):
|
|||||||
|
|
||||||
self.client.post(
|
self.client.post(
|
||||||
f'/apps/dashboard/{correct_list.id}/',
|
f'/apps/dashboard/{correct_list.id}/',
|
||||||
data={'item_text': 'A new item for an existing list'},
|
data={'text': 'A new item for an existing list'},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEqual(Item.objects.count(), 1)
|
self.assertEqual(Item.objects.count(), 1)
|
||||||
@@ -89,7 +89,7 @@ class DashViewTest(TestCase):
|
|||||||
|
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
f'/apps/dashboard/{correct_list.id}/',
|
f'/apps/dashboard/{correct_list.id}/',
|
||||||
data={'item_text': 'A new item for an existing list'},
|
data={'text': 'A new item for an existing list'},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertRedirects(response, f'/apps/dashboard/{correct_list.id}/')
|
self.assertRedirects(response, f'/apps/dashboard/{correct_list.id}/')
|
||||||
@@ -98,7 +98,7 @@ class DashViewTest(TestCase):
|
|||||||
list_ = List.objects.create()
|
list_ = List.objects.create()
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
f"/apps/dashboard/{list_.id}/",
|
f"/apps/dashboard/{list_.id}/",
|
||||||
data={"item_text": ""},
|
data={"text": ""},
|
||||||
)
|
)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertTemplateUsed(response, "apps/dashboard/list.html")
|
self.assertTemplateUsed(response, "apps/dashboard/list.html")
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ def home_page(request):
|
|||||||
|
|
||||||
def new_list(request):
|
def new_list(request):
|
||||||
nulist = List.objects.create()
|
nulist = List.objects.create()
|
||||||
item = Item(text=request.POST['item_text'], list=nulist)
|
item = Item(text=request.POST['text'], list=nulist)
|
||||||
try:
|
try:
|
||||||
item.full_clean()
|
item.full_clean()
|
||||||
item.save()
|
item.save()
|
||||||
@@ -25,7 +25,7 @@ def view_list(request, list_id):
|
|||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
try:
|
try:
|
||||||
item = Item(text=request.POST['item_text'], list=our_list)
|
item = Item(text=request.POST['text'], list=our_list)
|
||||||
item.full_clean()
|
item.full_clean()
|
||||||
item.save()
|
item.save()
|
||||||
return redirect(our_list)
|
return redirect(our_list)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<input
|
<input
|
||||||
class="form-control form-control-lg{% if error %} is-invalid{% endif %}"
|
class="form-control form-control-lg{% if error %} is-invalid{% endif %}"
|
||||||
name="item_text"
|
name="text"
|
||||||
id="id-new-item"
|
id="id-new-item"
|
||||||
placeholder="Enter a to-do item"
|
placeholder="Enter a to-do item"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user