fixed address for map

This commit is contained in:
SlimusMinus
2026-10-15 00:02:10 +03:00
parent 9eae82f6df
commit 01ac227bdb
7 changed files with 35 additions and 1 deletions

View File

@@ -284,6 +284,23 @@ class AdminPostServiceTest {
assertThat(post.getCity()).isEqualTo("Тверь");
}
@Test
void updatePost_keepsClientAddressAndTakesCityFromGeocoder() {
Post post = post(1L, PostStatus.ACTIVE);
when(postRepository.findById(1L)).thenReturn(java.util.Optional.of(post));
when(postRepository.save(any(Post.class))).thenAnswer(inv -> inv.getArgument(0));
when(geocodingService.getAddress("55.0", "37.0"))
.thenReturn(new com.krylov.refound.dto.AddressInfo("Москва", "Тверской район"));
AdminPostResponse dto = service.updatePost(1L, "LOSS", "Кот", " Москва, Тверская улица, 7 ",
55.0, 37.0, null, null, null, false, null, List.of(), "[]");
assertThat(post.getAddress()).isEqualTo("Москва, Тверская улица, 7");
assertThat(post.getCity()).isEqualTo("Москва");
assertThat(post.getDistrict()).isEqualTo("Тверской район");
assertThat(dto.getAddress()).isEqualTo("Москва, Тверская улица, 7");
}
@Test
void updateStatus_closesPostAndIncrementsStatistics() {
Post post = post(1L, PostStatus.ACTIVE);