Skip to content

Commit

Permalink
fix: task returned from content_render missing task_id (#339)
Browse files Browse the repository at this point in the history
  • Loading branch information
toph-allen authored Nov 27, 2024
1 parent 2cc15dc commit 31fee40
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
- The new `get_group_content()` function lets you view the content that groups
have permission to access. (#334)

## Minor improvements and fixes

- The task returned by `content_render()` now has the expected `task_id`
parameter and is able to be polled. (#338)

# connectapi 0.4.0

## New features
Expand Down
1 change: 0 additions & 1 deletion R/parse.R
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ tzone <- function(x) {
attr(x, "tzone")[[1]] %||% ""
}


new_datetime <- function(x = double(), tzone = "") {
tzone <- tzone %||% ""
if (is.integer(x)) {
Expand Down
5 changes: 3 additions & 2 deletions R/variant.R
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ VariantTask <- R6::R6Class(
#' @param task The task data.
initialize = function(connect, content, key, task) {
super$initialize(connect = connect, content = content, key = key)
# TODO: need to validate task (needs task_id)
if (is.null(task$task_id)) {
task$task_id <- task$id
}
self$task <- task
},
#' @description Return the underlying task.
Expand Down Expand Up @@ -302,7 +304,6 @@ variant_render <- function(variant) {
validate_R6_class(variant, "Variant")

rendered <- variant$render()
rendered$task_id <- rendered$id

VariantTask$new(connect = variant$get_connect(), content = variant$get_content(), key = variant$key, task = rendered)
}
Expand Down
9 changes: 9 additions & 0 deletions tests/integrated/test-content.R
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,15 @@ test_that("variant_render works", {
suppressMessages(poll_task(rnd2))
})

test_that("content_render works", {
rnd <- content_render(rmd_content)

expect_true(validate_R6_class(rnd, "VariantTask"))

# wait for tasks to complete...
suppressMessages(poll_task(rnd))
})

test_that("get_variant_renderings works", {
scoped_experimental_silence()

Expand Down

0 comments on commit 31fee40

Please sign in to comment.