8000 Fix see other response · sablesoft/laravel-json-api@331c66c · GitHub
[go: up one dir, main page]

Skip to content

Commit 331c66c

Browse files
committed
Fix see other response
1 parent 61fb815 commit 331c66c

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
@@ -288,7 +288,8 @@ public function accepted(AsynchronousProcess $job, array $links = [], $meta = nu
288288
public function process(AsynchronousProcess $job, array $links = [], $meta = null, array $headers = [])
289289
{
290290
if (!$job->isPending() && $location = $job->getLocation()) {
291-
return response()->redirectTo($location, Response::HTTP_SEE_OTHER, $headers);
291+
$headers['Location'] = $location;
292+
return $this->createJsonApiResponse(null, Response::HTTP_SEE_OTHER, $headers);
292293
}
293294

294295
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 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