Skip to content

Commit

Permalink
Fix typo in latest_common_approval
Browse files Browse the repository at this point in the history
Hopefully, this code is no longer in use and the typo did not affect too
many users. 🙈
  • Loading branch information
francoisfreitag committed May 9, 2024
1 parent 4985818 commit ad83ddb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion itou/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ def latest_common_approval(self):
self.latest_approval
and self.latest_approval.is_in_waiting_period
and self.latest_pe_approval
and self.latest_pe_approval.is_valid
and self.latest_pe_approval.is_valid()
):
return self.latest_pe_approval

Expand Down
15 changes: 15 additions & 0 deletions tests/users/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,21 @@ def test_latest_common_approval_when_only_pe_approval(self):
pe_approval = PoleEmploiApprovalFactory(nir=user.jobseeker_profile.nir)
assert user.latest_common_approval == pe_approval

def test_latest_common_approval_with_expired_pe_approval(self):
user = JobSeekerFactory()
today = timezone.localdate()
PoleEmploiApprovalFactory(
nir=user.jobseeker_profile.nir,
start_at=today - datetime.timedelta(days=30),
end_at=today - datetime.timedelta(days=1),
)
approval = ApprovalFactory(
user=user,
start_at=today - datetime.timedelta(days=10),
end_at=today - datetime.timedelta(days=7),
)
assert user.latest_common_approval == approval

def test_latest_common_approval_is_approval_if_valid(self):
user = JobSeekerFactory()
approval = ApprovalFactory(user=user)
Expand Down

0 comments on commit ad83ddb

Please sign in to comment.