mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 13:12:50 +01:00
fixeS
This commit is contained in:
parent
08e4f9724f
commit
1986714927
@ -16,8 +16,6 @@ class EditClientRequest extends Request
|
||||
public function authorize()
|
||||
{
|
||||
return $this->user()->can('edit', $this->client);
|
||||
//return true;
|
||||
// return ! auth()->user(); //todo permissions
|
||||
}
|
||||
|
||||
public function sanitize()
|
||||
|
@ -27,10 +27,12 @@ class UpdateClientRequest extends Request
|
||||
|
||||
$contacts = request('contacts');
|
||||
|
||||
if(is_array($contacts))
|
||||
{
|
||||
for ($i = 0; $i < count($contacts); $i++) {
|
||||
$rules['contacts.' . $i . '.email'] = 'required|email|unique:client_contacts,email,' . $contacts[$i]['id'];
|
||||
}
|
||||
|
||||
}
|
||||
return $rules;
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ class RouteServiceProvider extends ServiceProvider
|
||||
|
||||
Route::bind('client', function ($value) {
|
||||
$client = \App\Models\Client::withTrashed()->where('id', $this->decodePrimaryKey($value))->first() ?? abort(404);
|
||||
//$client->load('contacts', 'primary_contact');
|
||||
$client->with('contacts', 'primary_contact','country');
|
||||
return $client;
|
||||
});
|
||||
|
||||
|
@ -11,7 +11,7 @@ use App\Models\ClientContact;
|
||||
class ClientContactRepository extends BaseRepository
|
||||
{
|
||||
|
||||
public function save(array $contacts, Client $client) : void
|
||||
public function save($contacts, Client $client) : void
|
||||
{
|
||||
|
||||
/* Convert array to collection */
|
||||
|
@ -32,6 +32,9 @@ class AccountTest extends TestCase
|
||||
Model::reguard();
|
||||
}
|
||||
|
||||
/*
|
||||
* @covers AccountController
|
||||
*/
|
||||
public function testAccountCreation()
|
||||
{
|
||||
$data = [
|
||||
|
@ -70,7 +70,10 @@ class ClientTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
public function testClientShow()
|
||||
/*
|
||||
* @covers ClientController
|
||||
*/
|
||||
public function testClientRestEndPoints()
|
||||
{
|
||||
|
||||
$data = [
|
||||
@ -118,6 +121,7 @@ class ClientTest extends TestCase
|
||||
});
|
||||
|
||||
$client = $account->default_company->clients()->first();
|
||||
$client->load('contacts');
|
||||
|
||||
|
||||
$response = $this->withHeaders([
|
||||
@ -133,6 +137,26 @@ class ClientTest extends TestCase
|
||||
])->get('/api/v1/clients/'.$this->encodePrimaryKey($client->id).'/edit');
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
$client_update = [
|
||||
'name' => 'A Funky Name'
|
||||
];
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $token,
|
||||
])->put('/api/v1/clients/'.$this->encodePrimaryKey($client->id), $client_update)
|
||||
->assertJson([
|
||||
'name' => 'A Funky Name'
|
||||
]);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $token,
|
||||
])->delete('/api/v1/clients/'.$this->encodePrimaryKey($client->id));
|
||||
|
||||
$response->assertStatus(200);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user