mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 17:54:30 -04:00
Fixes for download routes
This commit is contained in:
parent
86015c66e0
commit
adfff8e090
@ -701,12 +701,9 @@ class InvoiceController extends BaseController
|
||||
break;
|
||||
case 'download':
|
||||
|
||||
$file = $invoice->service()->getInvoicePdf();
|
||||
$filename = $invoice->getFileName();
|
||||
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo $file;
|
||||
}, $filename, ['Content-Type' => 'application/pdf']);
|
||||
return response()->streamDownload(function () use ($invoice) {
|
||||
echo $invoice->service()->getInvoicePdf();
|
||||
}, $invoice->getFileName(), ['Content-Type' => 'application/pdf']);
|
||||
|
||||
case 'restore':
|
||||
$this->invoice_repo->restore($invoice);
|
||||
|
@ -720,11 +720,9 @@ class QuoteController extends BaseController
|
||||
break;
|
||||
case 'download':
|
||||
|
||||
$file = $quote->service()->getQuotePdf();
|
||||
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo $file;
|
||||
}, $quote->numberFormatter().".pdf", ['Content-Type' => 'application/pdf']);
|
||||
return response()->streamDownload(function () use ($quote) {
|
||||
echo $quote->service()->getQuotePdf();
|
||||
}, $quote->getFileName(), ['Content-Type' => 'application/pdf']);
|
||||
|
||||
case 'restore':
|
||||
$this->quote_repo->restore($quote);
|
||||
@ -833,11 +831,9 @@ class QuoteController extends BaseController
|
||||
$headers = array_merge($headers, ['Content-Disposition' => 'inline']);
|
||||
}
|
||||
|
||||
$file = $quote->service()->getQuotePdf($contact);
|
||||
|
||||
return response()->streamDownload(function () use ($file) {
|
||||
echo $file;
|
||||
}, $quote->numberFormatter().".pdf", $headers);
|
||||
return response()->streamDownload(function () use ($quote,$contact) {
|
||||
echo $quote->service()->getQuotePdf($contact);
|
||||
}, $quote->getFileName(), $headers);
|
||||
|
||||
}
|
||||
|
||||
|
@ -249,7 +249,6 @@ class BaseModel extends Model
|
||||
|
||||
return \Illuminate\Support\Str::ascii($formatted_number);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,6 +82,34 @@ class DownloadHistoricalInvoiceTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
public function testDownloadQuoteRoute()
|
||||
{
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->get("/api/v1/quotes/{$this->quote->hashed_id}/download");
|
||||
|
||||
$response->assertStatus(200);
|
||||
$response->assertDownload();
|
||||
|
||||
}
|
||||
|
||||
public function testDownloadQuoteBulkActionRoute()
|
||||
{
|
||||
$data = [
|
||||
'action' => 'download',
|
||||
'ids' => [$this->quote->hashed_id],
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post("/api/v1/quotes/bulk", $data);
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
private function mockActivity()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user