Skip to content
Snippets Groups Projects
Commit 48b05fb8 authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add tests for the applicant dashboard

parent 24fb416f
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,13 @@ ...@@ -28,7 +28,13 @@
</div> </div>
{% include "funds/includes/status_bar.html" with phases=submission.workflow current_phase=submission.phase class="status-bar--small" %} {% include "funds/includes/status_bar.html" with phases=submission.workflow current_phase=submission.phase class="status-bar--small" %}
{% if request.user|has_edit_perm:submission %} {% if request.user|has_edit_perm:submission %}
<a class="button button--primary" href="{% url 'funds:submissions:edit' submission.id %}">Start your {{ submission.stage }} application</a> <a class="button button--primary" href="{% url 'funds:submissions:edit' submission.id %}">
{% if submission.status == 'draft_proposal' %}
Start your {{ submission.stage }} application
{% else %}
Edit
{% endif %}
</a>
{% endif %} {% endif %}
</div> </div>
{% empty %} {% empty %}
......
from opentech.apply.funds.tests.factories import ApplicationSubmissionFactory
from opentech.apply.users.tests.factories import UserFactory
from opentech.apply.utils.tests import BaseViewTestCase
class TestApplicantDashboard(BaseViewTestCase):
user_factory = UserFactory
url_name = 'dashboard:{}'
base_view_name = 'dashboard'
def test_can_access_dashboard_with_active(self):
application = ApplicationSubmissionFactory(user=self.user, form_data__title='Improve the internet')
response = self.get_page()
self.assertContains(response, application.title)
self.assertNotContains(response, 'Submission history')
def test_can_not_access_other_users_active(self):
application = ApplicationSubmissionFactory(form_data__title='Ruin the internet')
response = self.get_page()
self.assertNotContains(response, application.title)
self.assertNotContains(response, 'Submission history')
def test_gets_invite_if_invited_to_proposal(self):
ApplicationSubmissionFactory(user=self.user, draft_proposal=True)
response = self.get_page()
self.assertContains(response, 'Start your ')
def test_no_invite_if_can_edit(self):
ApplicationSubmissionFactory(user=self.user, status='concept_more_info', workflow_stages=2)
response = self.get_page()
self.assertNotContains(response, 'Start your ')
self.assertContains(response, 'Edit', 1)
def test_no_edit_if_in_review(self):
ApplicationSubmissionFactory(user=self.user, status='internal_review')
response = self.get_page()
self.assertNotContains(response, 'Edit')
self.assertNotContains(response, 'Submission history')
...@@ -186,6 +186,10 @@ class ApplicationSubmissionFactory(factory.DjangoModelFactory): ...@@ -186,6 +186,10 @@ class ApplicationSubmissionFactory(factory.DjangoModelFactory):
class Params: class Params:
workflow_stages = 1 workflow_stages = 1
draft_proposal = factory.Trait(
status='draft_proposal',
workflow_name='double',
)
form_fields = blocks.CustomFormFieldsFactory form_fields = blocks.CustomFormFieldsFactory
form_data = factory.SubFactory(FormDataFactory, form_fields=factory.SelfAttribute('..form_fields')) form_data = factory.SubFactory(FormDataFactory, form_fields=factory.SelfAttribute('..form_fields'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment