Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 식단 이미지 업로드 알림 운영시간 검사 추가 #744

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ public void saveDiningImage(DiningImageRequest imageRequest) {
boolean isImageExist = diningRepository.existsByDateAndTypeAndImageUrlIsNotNull(dining.getDate(),
dining.getType());

if (!isImageExist) {
LocalDateTime now = LocalDateTime.now(clock);
boolean isOpened = coopShopService.getIsOpened(now, CoopShopType.CAFETERIA, dining.getType());

if (isOpened && !isImageExist) {
eventPublisher.publishEvent(new DiningImageUploadEvent(dining.getImageUrl()));
}

Expand Down
46 changes: 46 additions & 0 deletions src/test/java/in/koreatech/koin/acceptance/DiningApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,50 @@ void checkIsLikedFalse() {
]
""");
}

@Test
@DisplayName("이미지 업로드를 한다. - 품절 알림이 발송된다.")
void checkImageUploadNotification() {
String imageUrl = "https://stage.koreatech.in/image.jpg";
given()
.contentType(ContentType.JSON)
.header("Authorization", "Bearer " + token_준기)
.body(String.format("""
{
"menu_id": "%s",
"image_url": "%s"
}
""", A코너_점심.getId(), imageUrl))
.when()
.patch("/coop/dining/image")
.then()
.statusCode(HttpStatus.OK.value())
.extract();

verify(coopEventListener).onDiningImageUploadRequest(any());
}

@Test
@DisplayName("해당 식사시간 외에 이미지 업로드를 한다. - 품절 알림이 발송되지 않는다.")
void checkImageUploadNotificationAfterHours() {
Dining A코너_저녁 = diningFixture.A코스_저녁(LocalDate.parse("2024-01-15"));
String imageUrl = "https://stage.koreatech.in/image.jpg";

given()
.contentType(ContentType.JSON)
.header("Authorization", "Bearer " + token_준기)
.body(String.format("""
{
"menu_id": "%s",
"image_url": "%s"
}
""", A코너_저녁.getId(), imageUrl))
.when()
.patch("/coop/dining/image")
.then()
.statusCode(HttpStatus.OK.value())
.extract();

verify(coopEventListener, never()).onDiningImageUploadRequest(any());
}
}
Loading