Skip to content

Commit

Permalink
Merge pull request #148 from AEM5299/issue-147
Browse files Browse the repository at this point in the history
Fixes failure when passing empty string as content
  • Loading branch information
tonysm authored Jun 14, 2024
2 parents fa6b03b + d506c7c commit d470a80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Http/PendingTurboStreamResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ private function contentAsRendering()
*/
public function toResponse($request)
{
if (! in_array($this->useAction, ['remove', 'refresh']) && ! $this->partialView && ! $this->inlineContent) {
if (! in_array($this->useAction, ['remove', 'refresh']) && ! $this->partialView && $this->inlineContent === null) {
throw TurboStreamResponseFailedException::missingPartial();
}

Expand Down
17 changes: 17 additions & 0 deletions tests/Http/ResponseMacrosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,23 @@ public function response_builder_fails_when_partial_is_missing_and_not_a_remove_
->toResponse(new Request);
}

/** @test */
public function response_builder_doesnt_fail_when_partial_is_empty_string()
{
$response = response()
->turboStream()
->update('example_target', '')
->toResponse(new Request);

$expected = view('turbo-laravel::turbo-stream', [
'action' => 'update',
'target' => 'example_target',
'content' => '',
])->render();

$this->assertEquals(trim($expected), trim($response->getContent()));
}

/** @test */
public function refresh_shorthand()
{
Expand Down

0 comments on commit d470a80

Please sign in to comment.