Skip to content

Commit

Permalink
Merge branch 'master' into release/parent-3.12.0-52
Browse files Browse the repository at this point in the history
  • Loading branch information
domonkosadam committed Oct 7, 2024
2 parents 0e99ec4 + 882e593 commit 2a0b1d4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import android.content.res.Resources
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.ical.values.DateValueImpl
import com.google.ical.values.DateTimeValueImpl
import com.google.ical.values.Frequency
import com.google.ical.values.RRule
import com.google.ical.values.Weekday
Expand Down Expand Up @@ -644,7 +644,7 @@ class CreateUpdateEventViewModel @Inject constructor(
}
if (customFrequencyUiState.selectedDate != null) {
val date = customFrequencyUiState.selectedDate
until = DateValueImpl(date.year, date.monthValue, date.dayOfMonth)
until = DateTimeValueImpl(date.year, date.monthValue, date.dayOfMonth, 0, 0, 0)
} else {
count = customFrequencyUiState.selectedOccurrences
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,33 @@ class CreateUpdateEventViewModelTest {
}
}

@Test
fun `Frequency updates correctly - Custom with date until`() = runTest {
every { savedStateHandle.get<String>(CreateUpdateEventFragment.INITIAL_DATE) } returns "2024-04-10"

createViewModel()

viewModel.handleAction(CreateUpdateEventAction.UpdateCustomFrequencyQuantity(2))
viewModel.handleAction(CreateUpdateEventAction.UpdateCustomFrequencySelectedTimeUnitIndex(1))
viewModel.handleAction(CreateUpdateEventAction.UpdateCustomFrequencySelectedDays(setOf(DayOfWeek.MONDAY, DayOfWeek.TUESDAY)))
viewModel.handleAction(CreateUpdateEventAction.UpdateCustomFrequencyEndDate(LocalDate.of(2024, 10, 7)))
viewModel.handleAction(CreateUpdateEventAction.SaveCustomFrequency)
viewModel.handleAction(CreateUpdateEventAction.Save(CalendarEventAPI.ModifyEventScope.ONE))

coVerify(exactly = 1) {
repository.createEvent(
any(),
any(),
any(),
"FREQ=WEEKLY;UNTIL=20241007T000000Z;INTERVAL=2;BYDAY=MO,TU",
any(),
any(),
any(),
any()
)
}
}

private fun createViewModel() {
viewModel = CreateUpdateEventViewModel(savedStateHandle, resources, repository, apiPrefs)
}
Expand Down

0 comments on commit 2a0b1d4

Please sign in to comment.