diff --git a/src/registrar/admin.py b/src/registrar/admin.py index e0c98b7c2..37535f1a2 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1600,12 +1600,8 @@ class DomainAdmin(ListHeaderAdmin): # No expiration date was found. Return none. extra_context["extended_expiration_date"] = None return super().changeform_view(request, object_id, form_url, extra_context) - - if curr_exp_date < date.today(): - extra_context["extended_expiration_date"] = date.today() + relativedelta(years=years_to_extend_by) - else: - new_date = domain.registry_expiration_date + relativedelta(years=years_to_extend_by) - extra_context["extended_expiration_date"] = new_date + new_date = curr_exp_date + relativedelta(years=years_to_extend_by) + extra_context["extended_expiration_date"] = new_date else: extra_context["extended_expiration_date"] = None diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py index 368f30721..4cb66c534 100644 --- a/src/registrar/tests/test_admin.py +++ b/src/registrar/tests/test_admin.py @@ -74,11 +74,10 @@ class TestDomainAdmin(MockEppLib, WebTest): ) super().setUp() - @skip("TODO for another ticket. This test case is grabbing old db data.") @patch("registrar.admin.DomainAdmin._get_current_date", return_value=date(2024, 1, 1)) def test_extend_expiration_date_button(self, mock_date_today): """ - Tests if extend_expiration_date button extends correctly + Tests if extend_expiration_date modal gives an accurate date """ # Create a ready domain with a preset expiration date @@ -105,17 +104,11 @@ class TestDomainAdmin(MockEppLib, WebTest): # Follow the response response = response.follow() - # refresh_from_db() does not work for objects with protected=True. - # https://github.com/viewflow/django-fsm/issues/89 - new_domain = Domain.objects.get(id=domain.id) - - # Check that the current expiration date is what we expect - self.assertEqual(new_domain.expiration_date, date(2025, 5, 25)) - # Assert that everything on the page looks correct self.assertEqual(response.status_code, 200) self.assertContains(response, domain.name) self.assertContains(response, "Extend expiration date") + self.assertContains(response, "New expiration date: May 25, 2025") # Ensure the message we recieve is in line with what we expect expected_message = "Successfully extended the expiration date." @@ -127,6 +120,7 @@ class TestDomainAdmin(MockEppLib, WebTest): extra_tags="", fail_silently=False, ) + mock_add_message.assert_has_calls([expected_call], 1) @less_console_noise_decorator