Skip to content

Commit d470a80

Browse files
authored
Merge pull request #148 from AEM5299/issue-147
Fixes failure when passing empty string as content
2 parents fa6b03b + d506c7c commit d470a80

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Http/PendingTurboStreamResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ private function contentAsRendering()
327327
*/
328328
public function toResponse($request)
329329
{
330-
if (! in_array($this->useAction, ['remove', 'refresh']) && ! $this->partialView && ! $this->inlineContent) {
330+
if (! in_array($this->useAction, ['remove', 'refresh']) && ! $this->partialView && $this->inlineContent === null) {
331331
throw TurboStreamResponseFailedException::missingPartial();
332332
}
333333

tests/Http/ResponseMacrosTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,23 @@ public function response_builder_fails_when_partial_is_missing_and_not_a_remove_
981981
->toResponse(new Request);
982982
}
983983

984+
/** @test */
985+
public function response_builder_doesnt_fail_when_partial_is_empty_string()
986+
{
987+
$response = response()
988+
->turboStream()
989+
->update('example_target', '')
990+
->toResponse(new Request);
991+
992+
$expected = view('turbo-laravel::turbo-stream', [
993+
'action' => 'update',
994+
'target' => 'example_target',
995+
'content' => '',
996+
])->render();
997+
998+
$this->assertEquals(trim($expected), trim($response->getContent()));
999+
}
1000+
9841001
/** @test */
9851002
public function refresh_shorthand()
9861003
{

0 commit comments

Comments
 (0)