Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit c07d772

Browse files
author
Thomas Horta
authored
Merge pull request #2626 from wordpress-mobile/issue/2624-blogging-prompts-fetch
[Blogging Prompts] Return list of prompts when calling fetchPrompts
2 parents d577013 + ecd76f6 commit c07d772

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

example/src/test/java/org/wordpress/android/fluxc/store/bloggingprompts/BloggingPromptsStoreTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class BloggingPromptsStoreTest {
191191
}
192192

193193
@Test
194-
fun `when fetch prompts triggered, then all prompt model are inserted into db`() = test {
194+
fun `when fetch prompts triggered, then all prompt models are inserted into db`() = test {
195195
val payload = BloggingPromptsPayload(PROMPTS_RESPONSE)
196196
whenever(
197197
restClient.fetchPrompts(
@@ -207,7 +207,7 @@ class BloggingPromptsStoreTest {
207207
}
208208

209209
@Test
210-
fun `given cards response, when fetch cards gets triggered, then empty cards model is returned`() =
210+
fun `given cards response, when fetch cards gets triggered, then all prompt models are returned in the result`() =
211211
test {
212212
val payload = BloggingPromptsPayload(PROMPTS_RESPONSE)
213213
whenever(
@@ -226,7 +226,7 @@ class BloggingPromptsStoreTest {
226226
requestedPromptDate
227227
)
228228

229-
assertThat(result.model).isNull()
229+
assertThat(result.model).isEqualTo(PROMPT_MODELS)
230230
assertThat(result.error).isNull()
231231
}
232232

fluxc/src/main/java/org/wordpress/android/fluxc/store/bloggingprompts/BloggingPromptsStore.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ class BloggingPromptsStore @Inject constructor(
8484
site: SiteModel,
8585
response: BloggingPromptsListResponse
8686
): BloggingPromptsResult<List<BloggingPromptModel>> = try {
87-
promptsDao.insertForSite(site.id, response.toBloggingPrompts())
88-
BloggingPromptsResult()
87+
val prompts = response.toBloggingPrompts()
88+
promptsDao.insertForSite(site.id, prompts)
89+
BloggingPromptsResult(prompts)
8990
} catch (e: Exception) {
9091
BloggingPromptsResult(BloggingPromptsError(GENERIC_ERROR))
9192
}

0 commit comments

Comments
 (0)