Merge pull request #183 from jonnybarnes/improving_media_endpoint_querying_aaronpk
Return null for media endpoint when no media exists
This commit is contained in:
commit
da0517382c
2 changed files with 3 additions and 2 deletions
|
@ -58,7 +58,7 @@ class MicropubMediaController extends Controller
|
|||
try {
|
||||
$media = Media::latest()->whereDate('created_at', '>=', Carbon::now()->subMinutes(30))->firstOrFail();
|
||||
} catch (ModelNotFoundException $exception) {
|
||||
return response()->json([], 404);
|
||||
return response()->json(['url' => null]);
|
||||
}
|
||||
|
||||
return response()->json(['url' => $media->url]);
|
||||
|
|
|
@ -28,7 +28,8 @@ class MicropubMediaTest extends TestCase
|
|||
'/api/media?q=last',
|
||||
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
|
||||
);
|
||||
$response->assertStatus(404);
|
||||
$response->assertStatus(200);
|
||||
$response->assertJson(['url' => null]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
|
|
Loading…
Add table
Reference in a new issue