-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apply: Mask sender email when he left his organization
- Loading branch information
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from tests.companies.factories import CompanyMembershipFactory | ||
from tests.job_applications.factories import JobApplicationFactory, JobApplicationSentByJobSeekerFactory | ||
from tests.prescribers.factories import PrescriberMembershipFactory | ||
|
||
|
||
def test_sender_left_org_prescriber(): | ||
prescriber_membership = PrescriberMembershipFactory() | ||
job_app = JobApplicationFactory( | ||
sender=prescriber_membership.user, sender_prescriber_organization=prescriber_membership.organization | ||
) | ||
assert job_app.sender_left_org is False | ||
|
||
# membership is inactive | ||
prescriber_membership.is_active = False | ||
prescriber_membership.save(update_fields=["is_active"]) | ||
assert job_app.sender_left_org is True | ||
|
||
# prescriber is inactive | ||
prescriber_membership.is_active = True | ||
prescriber_membership.save(update_fields=["is_active"]) | ||
prescriber_membership.user.is_active = False | ||
prescriber_membership.user.save(update_fields=["is_active"]) | ||
assert job_app.sender_left_org is True | ||
|
||
# membership was removed | ||
prescriber_membership.user.is_active = True | ||
prescriber_membership.user.save(update_fields=["is_active"]) | ||
prescriber_membership.delete() | ||
assert job_app.sender_left_org is True | ||
|
||
|
||
def test_sender_left_org_employer(): | ||
company_membership = CompanyMembershipFactory() | ||
job_app = JobApplicationFactory(sender=company_membership.user, sender_company=company_membership.company) | ||
assert job_app.sender_left_org is False | ||
|
||
# membership is inactive | ||
company_membership.is_active = False | ||
company_membership.save(update_fields=["is_active"]) | ||
assert job_app.sender_left_org is True | ||
|
||
# prescriber is inactive | ||
company_membership.is_active = True | ||
company_membership.save(update_fields=["is_active"]) | ||
company_membership.user.is_active = False | ||
company_membership.user.save(update_fields=["is_active"]) | ||
assert job_app.sender_left_org is True | ||
|
||
# membership was removed | ||
company_membership.user.is_active = True | ||
company_membership.user.save(update_fields=["is_active"]) | ||
company_membership.delete() | ||
assert job_app.sender_left_org is True | ||
|
||
|
||
def test_sender_left_org_job_seeker(): | ||
job_app = JobApplicationSentByJobSeekerFactory() | ||
assert job_app.sender_left_org is False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters