Skip to content

Commit

Permalink
www.employees_views: make sure we show the last approval
Browse files Browse the repository at this point in the history
  • Loading branch information
xavfernandez committed Sep 12, 2024
1 parent 42f7442 commit b098245
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion itou/www/employees_views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def get_job_application(self, employee):
),
),
)
.last()
.order_by("-created_at")
.first()
)

def get_context_data(self, **kwargs):
Expand Down
19 changes: 19 additions & 0 deletions tests/www/employees_views/test_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from itou.job_applications.enums import JobApplicationState, SenderKind
from itou.utils.immersion_facile import immersion_search_url
from itou.utils.templatetags import format_filters
from itou.utils.templatetags.format_filters import format_approval_number
from itou.utils.urls import add_url_params
from tests.approvals.factories import (
Expand Down Expand Up @@ -104,6 +105,24 @@ def test_detail_view_no_job_application(self, client):
assertContains(response, "Informations du salarié")
assertContains(response, "Candidatures de ce salarié")

def test_multiple_approvals(self, client):
company = CompanyFactory(with_membership=True)
employer = company.members.first()
expired_approval = ApprovalFactory(expired=True)
JobApplicationFactory(
approval=expired_approval,
job_seeker=expired_approval.user,
to_company=company,
state=JobApplicationState.ACCEPTED,
)
new_approval = JobApplicationFactory(
job_seeker=expired_approval.user, to_company=company, with_approval=True
).approval
client.force_login(employer)
url = reverse("employees:detail", kwargs={"public_id": new_approval.user.public_id})
response = client.get(url)
assertContains(response, format_filters.format_approval_number(new_approval.number))

@pytest.mark.ignore_unknown_variable_template_error("with_matomo_event")
@freeze_time("2023-04-26")
def test_approval_status_includes(self, client, snapshot):
Expand Down

0 comments on commit b098245

Please sign in to comment.