Skip to content

Commit

Permalink
✏️ 가게사장의 쿠폰 조회 시 아직 만료되지 않은 쿠폰들만 보이도록 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty1434 committed Jan 16, 2024
1 parent 2f3145e commit 6117d9d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public List<CouponForOwnerDto> findAllDtoByStoreId(Long storeId, LocalDate now)
.where(
coupon.store.id.eq(storeId),
coupon.isDeleted.isFalse(),
coupon.endDate.loe(now)
coupon.endDate.goe(now)
)
.fetch();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ void readCouponsForOwner() {
// given
Store store = createStore(1L);
storeRepository.save(store);
Coupon c1 = createCoupon(store);
Coupon c2 = createCoupon(store);
couponRepository.saveAll(List.of(c1,c2));
LocalDate now = LocalDate.now().plusYears(1);
Coupon c1 = createCouponWithDate(store, now, now);
Coupon c2 = createCouponWithDate(store, now.minusDays(5), now.minusDays(1));
Coupon c3 = createCouponWithDate(store, now.plusDays(1), now.plusDays(5));
Coupon c4 = createCouponWithDate(store, now.minusDays(5), now.plusDays(5));

couponRepository.saveAll(List.of(c1,c2,c3,c4));

// when
List<CouponForOwnerDto> result = couponReader.readCouponsForOwner(store.getId(), LocalDate.now());
List<CouponForOwnerDto> result = couponReader.readCouponsForOwner(store.getId(), now);

// then
assertThat(result).hasSize(2);
assertThat(result).hasSize(3);

}
@DisplayName("아무도 발급받지 않은 쿠폰의 수량은 처음 설정과 동일하다")
Expand Down

0 comments on commit 6117d9d

Please sign in to comment.