mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for updating company user (#3401)
* update company schema descriptions * Fixes for company user controlleR
This commit is contained in:
parent
6b6fb6c807
commit
0f1c685bfa
@ -11,6 +11,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Exceptions\ModelNotFoundException;
|
||||
use App\Http\Requests\CompanyUser\UpdateCompanyUserRequest;
|
||||
use App\Models\CompanyUser;
|
||||
use App\Models\User;
|
||||
@ -128,19 +129,21 @@ class CompanyUserController extends BaseController
|
||||
{
|
||||
$company = auth()->user()->company();
|
||||
|
||||
if(auth()->user()->isAdmin()){
|
||||
$user_array = $request->all();
|
||||
|
||||
if(array_key_exists('company', $user_array));
|
||||
unset($user_array['company_user']);
|
||||
|
||||
$user->fill($user_array);
|
||||
$user->save();
|
||||
}
|
||||
|
||||
$company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first();
|
||||
|
||||
$company_user->fill($request->input('company_user'));
|
||||
if(!$company_user){
|
||||
throw new ModelNotFoundException("Company User record not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if(auth()->user()->isAdmin()){
|
||||
$company_user->fill($request->input('company_user'));
|
||||
}
|
||||
else {
|
||||
$company_user->fill($request->input('company_user')['settings']);
|
||||
}
|
||||
|
||||
$company_user->save();
|
||||
|
||||
return $this->itemResponse($company_user->fresh());
|
||||
|
@ -6,6 +6,8 @@
|
||||
* @OA\Property(property="id", type="string", example="WJxbojagwO", description="The company hash id"),
|
||||
* @OA\Property(property="size_id", type="string", example="1", description="The company size ID"),
|
||||
* @OA\Property(property="industry_id", type="string", example="1", description="The company industry ID"),
|
||||
* @OA\Property(property="slack_webhook_url", type="string", example="https://slack.com/sh328sj", description="The slack webhook notification URL"),
|
||||
* @OA\Property(property="google_analytics_url", type="string", example="1", description="The google analytics webhook notification URL"),
|
||||
* @OA\Property(property="portal_mode", type="string", example="subdomain", description="Determines the client facing urls ie: subdomain,domain,iframe"),
|
||||
* @OA\Property(property="subdomain", type="string", example="aceme", description="Specifies the first part of the company domain ie acme in acme.domain.com"),
|
||||
* @OA\Property(property="portal_domain", type="string", example="https://subdomain.invoicing.co", description="The fully qualified domain for client facing URLS"),
|
||||
|
@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Foundation\Testing\WithFaker;
|
||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Tests\MockAccountData;
|
||||
@ -43,6 +44,11 @@ class QuoteTest extends TestCase
|
||||
|
||||
$this->makeTestData();
|
||||
|
||||
$this->withoutMiddleware(
|
||||
ThrottleRequests::class
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testQuoteList()
|
||||
@ -60,12 +66,27 @@ class QuoteTest extends TestCase
|
||||
public function testQuoteRESTEndPoints()
|
||||
{
|
||||
|
||||
$response = $this->withHeaders([
|
||||
|
||||
|
||||
$response = null;
|
||||
|
||||
try{
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->get('/api/v1/quotes/'.$this->encodePrimaryKey($this->quote->id));
|
||||
}
|
||||
catch(ValidationException $e) {
|
||||
|
||||
$response->assertStatus(200);
|
||||
$message = json_decode($e->validator->getMessageBag(),1);
|
||||
|
||||
\Log::error($message);
|
||||
}
|
||||
|
||||
if($response)
|
||||
$response->assertStatus(200);
|
||||
|
||||
$this->assertNotNull($response);
|
||||
|
||||
$response = $this->withHeaders([
|
||||
'X-API-SECRET' => config('ninja.api_secret'),
|
||||
|
@ -13,6 +13,7 @@ use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers App\Http\Controllers\CompanyUserController
|
||||
*/
|
||||
class UpdateCompanyUserTest extends TestCase
|
||||
{
|
||||
@ -39,7 +40,6 @@ class UpdateCompanyUserTest extends TestCase
|
||||
|
||||
$this->user->company_user = $company_user;
|
||||
|
||||
$user['first_name'] = 'sausage';
|
||||
$user['company_user'] = $company_user->toArray();
|
||||
|
||||
$response = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user