mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 10:46:06 +02:00
added some additional test code to boost coverage, fixed is_portfolio_admin, and formatting
This commit is contained in:
parent
bcd4e57b4c
commit
9c0a7e15e8
3 changed files with 10 additions and 2 deletions
|
@ -259,7 +259,7 @@ class User(AbstractUser):
|
||||||
return self._has_portfolio_permission(portfolio, UserPortfolioPermissionChoices.EDIT_SUBORGANIZATION)
|
return self._has_portfolio_permission(portfolio, UserPortfolioPermissionChoices.EDIT_SUBORGANIZATION)
|
||||||
|
|
||||||
def is_portfolio_admin(self, portfolio):
|
def is_portfolio_admin(self, portfolio):
|
||||||
return self.has_edit_suborganization_portfolio_permission(portfolio)
|
return "Admin" in self.portfolio_role_summary(portfolio)
|
||||||
|
|
||||||
def get_first_portfolio(self):
|
def get_first_portfolio(self):
|
||||||
permission = self.portfolio_permissions.first()
|
permission = self.portfolio_permissions.first()
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
{% endblock breadcrumb %}
|
{% endblock breadcrumb %}
|
||||||
|
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
|
||||||
<div class="margin-top-4 tablet:grid-col-10">
|
<div class="margin-top-4 tablet:grid-col-10">
|
||||||
<h2 class="text-bold text-primary-dark domain-name-wrap">{{ domain.name }}</h2>
|
<h2 class="text-bold text-primary-dark domain-name-wrap">{{ domain.name }}</h2>
|
||||||
<div
|
<div
|
||||||
|
@ -78,6 +77,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
{% url 'domain-dns-nameservers' pk=domain.id as url %}
|
{% url 'domain-dns-nameservers' pk=domain.id as url %}
|
||||||
{% if domain.nameservers|length > 0 %}
|
{% if domain.nameservers|length > 0 %}
|
||||||
{% include "includes/summary_item.html" with title='DNS name servers' domains='true' value=domain.nameservers list='true' edit_link=url editable=is_editable %}
|
{% include "includes/summary_item.html" with title='DNS name servers' domains='true' value=domain.nameservers list='true' edit_link=url editable=is_editable %}
|
||||||
|
|
|
@ -142,6 +142,7 @@ class TestWithDomainPermissions(TestWithUser):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
try:
|
try:
|
||||||
UserDomainRole.objects.all().delete()
|
UserDomainRole.objects.all().delete()
|
||||||
|
DomainInvitation.objects.all().delete()
|
||||||
if hasattr(self.domain, "contacts"):
|
if hasattr(self.domain, "contacts"):
|
||||||
self.domain.contacts.all().delete()
|
self.domain.contacts.all().delete()
|
||||||
DomainRequest.objects.all().delete()
|
DomainRequest.objects.all().delete()
|
||||||
|
@ -382,6 +383,8 @@ class TestDomainDetail(TestDomainOverview):
|
||||||
)
|
)
|
||||||
# Check that user does not have option to Edit domain
|
# Check that user does not have option to Edit domain
|
||||||
self.assertNotContains(detail_page, "Edit")
|
self.assertNotContains(detail_page, "Edit")
|
||||||
|
# Check that invited domain manager section not displayed when no invited domain managers
|
||||||
|
self.assertNotContains(detail_page, "Invited domain managers")
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
@override_flag("organization_feature", active=True)
|
@override_flag("organization_feature", active=True)
|
||||||
|
@ -404,6 +407,8 @@ class TestDomainDetail(TestDomainOverview):
|
||||||
UserPortfolioPermission.objects.get_or_create(
|
UserPortfolioPermission.objects.get_or_create(
|
||||||
user=user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN]
|
user=user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN]
|
||||||
)
|
)
|
||||||
|
# add a domain invitation
|
||||||
|
DomainInvitation.objects.get_or_create(email="invited@example.com", domain=domain)
|
||||||
user.refresh_from_db()
|
user.refresh_from_db()
|
||||||
self.client.force_login(user)
|
self.client.force_login(user)
|
||||||
detail_page = self.client.get(f"/domain/{domain.id}")
|
detail_page = self.client.get(f"/domain/{domain.id}")
|
||||||
|
@ -414,6 +419,9 @@ class TestDomainDetail(TestDomainOverview):
|
||||||
)
|
)
|
||||||
# Check that user does not have option to Edit domain
|
# Check that user does not have option to Edit domain
|
||||||
self.assertNotContains(detail_page, "Edit")
|
self.assertNotContains(detail_page, "Edit")
|
||||||
|
# Check that invited domain manager is displayed
|
||||||
|
self.assertContains(detail_page, "Invited domain managers")
|
||||||
|
self.assertContains(detail_page, "invited@example.com")
|
||||||
|
|
||||||
|
|
||||||
class TestDomainManagers(TestDomainOverview):
|
class TestDomainManagers(TestDomainOverview):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue