8000 Merge branch 'feature/async' into async-with-cn · sablesoft/laravel-json-api@04a4c93 · GitHub
[go: up one dir, main page]

Skip to content

Commit 04a4c93

Browse files
committed
Merge branch 'feature/async' into async-with-cn
2 parents 0845222 + 331c66c commit 04a4c93

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Http/Responses/Responses.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,8 @@ public function accepted(AsynchronousProcess $job, array $links = [], $meta = nu
315315
public function process(AsynchronousProcess $job, array $links = [], $meta = null, array $headers = [])
316316
{
317317
if (!$job->isPending() && $location = $job->getLocation()) {
318-
return response()->redirectTo($location, Response::HTTP_SEE_OTHER, $headers);
318+
$headers['Location'] = $location;
319+
return $this->createJsonApiResponse(null, Response::HTTP_SEE_OTHER, $headers);
319320
}
320321

321322
return $this->getContentResponse($job, self::HTTP_OK, $links, $meta, $headers);

tests/lib/Integration/Queue/QueueJobsTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,20 @@ public function testReadPending()
3434

3535
/**
3636
* When job process is done, the request SHOULD return a status 303 See other
37-
* with A87A a link in Location header.
37+
* with a link in Location header. The spec recommendation shows a response with
38+
* a Content-Type header as `application/vnd.api+json` but no content in the response body.
3839
*/
3940
public function testReadNotPending()
4041
{
4142
$job = factory(ClientJob::class)->states('success')->create();
42-
$location = "http://localhost/api/v1/downloads/{$job->resource_id}";
4343

44-
$this->getJsonApi($this->jobUrl($job))
44+
$response = $this
45+
->getJsonApi($this->jobUrl($job))
4546
->assertStatus(303)
46-
->assertHeader('Location', $location);
47+
->assertLocation('/api/v1/downloads/' . $job->resource_id)
48+
->assertHeader('Content-Type', 'application/vnd.api+json');
49+
50+
$this->assertEmpty($response->getContent(), 'content is empty.');
4751
}
4852

4953
/**

0 commit comments

Comments
 (0)
0