mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-19 17:25:56 +02:00
Merge pull request #2148 from cisagov/rh/1793-remove-two-values
ISSUE #1793: Exclude gov Administration and Non-Federal Agency in Domain Request form
This commit is contained in:
commit
1cf4f5fc3c
2 changed files with 49 additions and 2 deletions
|
@ -97,6 +97,7 @@ class OrganizationElectionForm(RegistrarForm):
|
|||
|
||||
class OrganizationContactForm(RegistrarForm):
|
||||
# for federal agencies we also want to know the top-level agency.
|
||||
excluded_agencies = ["gov Administration", "Non-Federal Agency"]
|
||||
federal_agency = forms.ModelChoiceField(
|
||||
label="Federal agency",
|
||||
# not required because this field won't be filled out unless
|
||||
|
@ -104,9 +105,8 @@ class OrganizationContactForm(RegistrarForm):
|
|||
# if it has been filled in when required.
|
||||
# uncomment to see if modelChoiceField can be an arg later
|
||||
required=False,
|
||||
queryset=FederalAgency.objects.all(),
|
||||
queryset=FederalAgency.objects.exclude(agency__in=excluded_agencies),
|
||||
empty_label="--Select--",
|
||||
# choices=[("", "--Select--")] + DomainRequest.AGENCY_CHOICES,
|
||||
)
|
||||
organization_name = forms.CharField(
|
||||
label="Organization name",
|
||||
|
|
|
@ -723,6 +723,53 @@ class DomainRequestTests(TestWithUser, WebTest):
|
|||
|
||||
self.assertContains(contact_page, self.TITLES[Step.ABOUT_YOUR_ORGANIZATION])
|
||||
|
||||
def test_federal_agency_dropdown_excludes_expected_values(self):
|
||||
"""The Federal Agency dropdown on a domain request form should not
|
||||
include options for gov Administration and Non-Federal Agency"""
|
||||
intro_page = self.app.get(reverse("domain-request:"))
|
||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||
# resetting the session key on each new request, thus destroying the concept
|
||||
# of a "session". We are going to do it manually, saving the session ID here
|
||||
# and then setting the cookie on each request.
|
||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||
|
||||
intro_form = intro_page.forms[0]
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
intro_result = intro_form.submit()
|
||||
|
||||
# follow first redirect
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
type_page = intro_result.follow()
|
||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||
|
||||
# ---- TYPE PAGE ----
|
||||
type_form = type_page.forms[0]
|
||||
type_form["generic_org_type-generic_org_type"] = "federal"
|
||||
|
||||
# test next button
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
type_result = type_form.submit()
|
||||
|
||||
# ---- FEDERAL BRANCH PAGE ----
|
||||
# Follow the redirect to the next form page
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
federal_page = type_result.follow()
|
||||
federal_form = federal_page.forms[0]
|
||||
federal_form["organization_federal-federal_type"] = "executive"
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
federal_result = federal_form.submit()
|
||||
|
||||
# ---- ORG CONTACT PAGE ----
|
||||
# Follow the redirect to the next form page
|
||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||
org_contact_page = federal_result.follow()
|
||||
|
||||
# gov Administration and Non-Federal Agency should not be federal agency options
|
||||
self.assertNotContains(org_contact_page, "gov Administration")
|
||||
self.assertNotContains(org_contact_page, "Non-Federal Agency")
|
||||
# make sure correct federal agency options still show up
|
||||
self.assertContains(org_contact_page, "General Services Administration")
|
||||
|
||||
def test_yes_no_contact_form_inits_blank_for_new_domain_request(self):
|
||||
"""On the Other Contacts page, the yes/no form gets initialized with nothing selected for
|
||||
new domain requests"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue