Skip to content
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 @@ -51,6 +51,7 @@ class ReviewRepositoryImpl @Inject constructor(private val reviewService: Review
}

override suspend fun writeMenuReview(
menuId: Long,
rating: Int,
content: String,
imageUrls: List<String>,
Expand All @@ -61,12 +62,10 @@ class ReviewRepositoryImpl @Inject constructor(private val reviewService: Review
rating = rating,
content = content,
imageUrls = imageUrls,
menuLike = likeMenuIdList?.firstOrNull()?.let {
WriteMenuReviewRequest.MenuLike(
menuId = it,
isLike = true,
)
}
menuLike = WriteMenuReviewRequest.MenuLike(
menuId = menuId,
isLike = likeMenuIdList?.contains(menuId) ?: false,
),
)
return reviewService.writeMenuReview(request).isSuccess()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface ReviewRepository {
): Boolean

suspend fun writeMenuReview(
menuId: Long,
rating: Int,
content: String,
imageUrls: List<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class WriteReviewUseCase @Inject constructor(
when (menuType) {
MenuType.FIXED -> {
return reviewRepository.writeMenuReview(
menuId = itemId,
rating = rating,
content = content,
imageUrls = if (imageUrl != null) listOf(imageUrl) else emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class BaseActivity<B : ViewBinding>(
) : AppCompatActivity() {

@Inject
protected lateinit var analyticsTracker: AnalyticsTracker
lateinit var analyticsTracker: AnalyticsTracker

private var _binding: B? = null
val binding get() = _binding!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ abstract class BaseFragment<B : ViewBinding>(
) : Fragment() {

@Inject
protected lateinit var analyticsTracker: AnalyticsTracker
lateinit var analyticsTracker: AnalyticsTracker

private var _binding: B? = null
val binding get() = _binding!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ class ReviewRepositoryImplBehaviorSpec : AppBehaviorSpec({
val requestSlot = slot<WriteMenuReviewRequest>()
coEvery { service.writeMenuReview(capture(requestSlot)) } returns ApiResult.Success(Unit)

then("첫 번째 likeMenuId만 menuLike로 매핑한다") {
then("menuId와 isLike를 menuLike로 전달한다") {
runTest {
repository.writeMenuReview(
menuId = 9L,
rating = 3,
content = "메뉴리뷰",
imageUrls = listOf("img"),
Expand All @@ -114,15 +115,19 @@ class ReviewRepositoryImplBehaviorSpec : AppBehaviorSpec({
val requestSlot = slot<WriteMenuReviewRequest>()
coEvery { service.writeMenuReview(capture(requestSlot)) } returns ApiResult.Success(Unit)

then("menuLike=null로 전달한다") {
then("menuLike.isLike=false로 전달한다") {
runTest {
repository.writeMenuReview(
menuId = 1L,
rating = 2,
content = "x",
imageUrls = emptyList(),
likeMenuIdList = null,
)
requestSlot.captured.menuLike shouldBe null
requestSlot.captured.menuLike shouldBe WriteMenuReviewRequest.MenuLike(
menuId = 1L,
isLike = false,
)
}
}
}
Expand All @@ -131,16 +136,20 @@ class ReviewRepositoryImplBehaviorSpec : AppBehaviorSpec({
val requestSlot = slot<WriteMenuReviewRequest>()
coEvery { service.writeMenuReview(capture(requestSlot)) } returns ApiResult.Success(Unit)

then("menuLike=null로 전달하고 정상 처리한다") {
then("menuLike.isLike=false로 전달하고 정상 처리한다") {
runTest {
repository.writeMenuReview(
menuId = 1L,
rating = 1,
content = "x",
imageUrls = emptyList(),
likeMenuIdList = emptyList(),
) shouldBe true

requestSlot.captured.menuLike shouldBe null
requestSlot.captured.menuLike shouldBe WriteMenuReviewRequest.MenuLike(
menuId = 1L,
isLike = false,
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class WriteReviewUseCaseBehaviorSpec : AppBehaviorSpec({
`when`("FIXED 메뉴에 이미지 없이 작성하면") {
coEvery {
reviewRepository.writeMenuReview(
menuId = 100L,
rating = 5,
content = "good",
imageUrls = emptyList(),
Expand All @@ -40,6 +41,7 @@ class WriteReviewUseCaseBehaviorSpec : AppBehaviorSpec({

coVerify(exactly = 1) {
reviewRepository.writeMenuReview(
menuId = 100L,
rating = 5,
content = "good",
imageUrls = emptyList(),
Expand All @@ -53,6 +55,7 @@ class WriteReviewUseCaseBehaviorSpec : AppBehaviorSpec({
`when`("FIXED 메뉴에 이미지가 있으면") {
coEvery {
reviewRepository.writeMenuReview(
menuId = 100L,
rating = 4,
content = "",
imageUrls = listOf("https://img"),
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ compressor = "3.0.1"
coroutines = "1.7.3"
kakao-login = "2.23.0"
kakao-talk = "2.23.0"
hilt = "2.50"
hilt = "2.52"
androidxHilt = "1.2.0"
play-services-base = "18.0.1"
firebase-bom = "32.6.0"
Expand Down
Loading