Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
For #12184 - Stop refreshing sponsored stories if profile is deleted
Browse files Browse the repository at this point in the history
This also allows to easily start a "new" Worker to download stories again when
`startPeriodicStoriesRefresh` whereas we'd just enqueue the existing one which
may be set to only refresh the stories after a few hours still.
  • Loading branch information
Mugurell authored and mergify[bot] committed May 26, 2022
1 parent d5ebfa2 commit 433dac8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class PocketStoriesService(
* Delete all stored user data used for downloading personalized sponsored stories.
*/
suspend fun deleteProfile(): Boolean {
stopPeriodicSponsoredStoriesRefresh()
return spocsUseCases?.deleteProfile?.invoke() ?: false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mockito.doReturn
import org.mockito.Mockito.never
import org.mockito.Mockito.spy
import org.mockito.Mockito.times
import org.mockito.Mockito.verify
import java.util.UUID
import kotlin.reflect.KVisibility
Expand Down Expand Up @@ -167,14 +169,16 @@ class PocketStoriesServiceTest {

@Test
fun `GIVEN PocketStoriesService WHEN deleteProfile THEN delegate to spocs useCases`() = runTest {
val noProfileResponse = service.deleteProfile()
val mockedService = spy(service)
val noProfileResponse = mockedService.deleteProfile()
assertFalse(noProfileResponse)

val deleteProfileUseCase: DeleteProfile = mock()
doReturn(deleteProfileUseCase).`when`(spocsUseCases).deleteProfile
doReturn(true).`when`(deleteProfileUseCase).invoke()
val existingProfileResponse = service.deleteProfile()
val existingProfileResponse = mockedService.deleteProfile()
assertTrue(existingProfileResponse)
verify(mockedService, times(2)).stopPeriodicSponsoredStoriesRefresh()
}

@Test
Expand Down

1 comment on commit 433dac8

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

Failed to fetch task artifact public/github/customCheckRunText.md for GitHub integration.
Make sure the artifact exists on the worker or other location.

Please sign in to comment.