0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00
Conflicts:
	wagtail/wagtailforms/tests.py
This commit is contained in:
Matt Westcott 2015-09-02 16:13:29 +01:00
parent 3cd348206f
commit 16b8173b80
4 changed files with 13 additions and 1 deletions

View File

@ -288,8 +288,12 @@ EventIndex.content_panels = [
class FormField(AbstractFormField):
page = ParentalKey('FormPage', related_name='form_fields')
class FormPage(AbstractEmailForm):
pass
def get_context(self, request):
context = super(FormPage, self).get_context(request)
context['greeting'] = "hello world"
return context
FormPage.content_panels = [
FieldPanel('title', classname="full title"),

View File

@ -2,6 +2,7 @@
{% load wagtailcore_tags %}
{% block content %}
<p>{{ greeting }}</p>
<form action="{% pageurl self %}" method="post">
{% csrf_token %}
{{ form.as_p }}

View File

@ -1,5 +1,6 @@
{% extends "tests/base.html" %}
{% block content %}
<p>{{ greeting }}</p>
<p>Thank you for your feedback.</p>
{% endblock %}

View File

@ -65,6 +65,9 @@ class TestFormSubmission(TestCase):
self.assertTemplateUsed(response, 'tests/form_page.html')
self.assertTemplateNotUsed(response, 'tests/form_page_landing.html')
# check that variables defined in get_context are passed through to the template (#1429)
self.assertContains(response, "<p>hello world</p>")
@mock.patch.object(AbstractForm, 'get_context', autospec=True)
def test_get_form_calls_get_context(self, get_context):
get_context.side_effect = Page.get_context
@ -97,6 +100,9 @@ class TestFormSubmission(TestCase):
self.assertTemplateNotUsed(response, 'tests/form_page.html')
self.assertTemplateUsed(response, 'tests/form_page_landing.html')
# check that variables defined in get_context are passed through to the template (#1429)
self.assertContains(response, "<p>hello world</p>")
# Check that an email was sent
self.assertEqual(len(mail.outbox), 1)
self.assertEqual(mail.outbox[0].subject, "The subject")