Add limiting exception

This commit is contained in:
David Bomba 2024-06-18 11:33:56 +10:00
parent 24a662f920
commit 7623246424
3 changed files with 47 additions and 3 deletions

View File

@ -0,0 +1,44 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace App\Exceptions;
use Exception;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DuplicatePaymentException extends Exception
{
/**
* Report the exception.
*
* @return void
*/
public function report()
{
//
}
/**
* Render the exception into an HTTP response.
*
* @param Request $request
* @return JsonResponse
*/
public function render($request)
{
return response()->json([
'message' => 'Duplicate request',
], 400);
}
}

View File

@ -1880,8 +1880,6 @@ class PaymentTest extends TestCase
$response->assertStatus(200); $response->assertStatus(200);
sleep(1);
$response = $this->withHeaders([ $response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'), 'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token, 'X-API-TOKEN' => $this->token,

View File

@ -97,7 +97,9 @@ class PurchaseOrderTest extends TestCase
public function testPurchaseOrderBulkActions() public function testPurchaseOrderBulkActions()
{ {
$i = $this->purchase_order->invitations->first(); $this->purchase_order->service()->createInvitations()->save();
$i = $this->purchase_order->fresh()->invitations->first();
$data = [ $data = [
'ids' =>[$this->purchase_order->hashed_id], 'ids' =>[$this->purchase_order->hashed_id],