1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Fixes for tests

This commit is contained in:
David Bomba 2020-06-27 14:09:16 +10:00
parent e6bc63b2c2
commit ae8a61cbcd
4 changed files with 39 additions and 11 deletions

View File

@ -28,7 +28,15 @@ class StoreUserRequest extends Request
*/
public function authorize() : bool
{
{
// info(print_r(auth()->user()->toArray(),1));
// info(print_r(auth()->user()->company_user->toArray(),1));
//
$queries = \DB::getQueryLog();
$count = count($queries);
info(request()->method() . ' - ' . request()->url() . ": $count queries - ");
return auth()->user()->isAdmin();
}
@ -43,8 +51,9 @@ class StoreUserRequest extends Request
$rules['email'] = new ValidUserForCompany();
}
if(auth()->user()->company()->account->isFreeHostedClient())
if(auth()->user()->company()->account->isFreeHostedClient()){
$rules['hosted_users'] = new CanAddUserRule(auth()->user()->company()->account);
}
return $rules;
}

View File

@ -196,9 +196,21 @@ class User extends Authenticatable implements MustVerifyEmail
$this->id = auth()->user()->id;
}
return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
->where('company_user.user_id', $this->id)
->withTrashed();
return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
->where('company_user.user_id', $this->id)
->withTrashed();
// if(request()->header('X-API-TOKEN')){
// return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
// ->where('company_tokens.token', request()->header('X-API-TOKEN'))
// ->withTrashed();
// }
// else {
// return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
// ->where('company_user.user_id', $this->id)
// ->withTrashed();
// }
}
/**

View File

@ -1,6 +1,6 @@
<footer class="bg-white px-4 py-5 shadow px-4 sm:px-6 md:px-8 flex justify-center border border-gray-200 justify-between items-center">
<span class="text-sm text-gray-700">{{ ctrans('texts.footer_label', ['year' => date('Y')]) }}</span>
@if(!auth()->user()->user->account->isPaid())
@if(auth()->user()->user && !auth()->user()->user->account->isPaid())
<a href="#">
<img class="h-8" src="{{ asset('images/invoiceninja-black-logo-2.png') }}" alt="Invoice Ninja Logo">
</a>

View File

@ -4,6 +4,7 @@ namespace Feature;
use App\Factory\CompanyUserFactory;
use App\Factory\UserFactory;
use App\Http\Middleware\PasswordProtection;
use App\Models\Account;
use App\Models\Activity;
use App\Models\Company;
@ -35,17 +36,18 @@ class UserTest extends TestCase
{
parent::setUp();
$this->withoutMiddleware(
ThrottleRequests::class
);
Session::start();
$this->faker = \Faker\Factory::create();
$this->makeTestData();
Model::reguard();
$this->makeTestData();
$this->withoutMiddleware(
ThrottleRequests::class,
PasswordProtection::class
);
}
@ -62,6 +64,8 @@ class UserTest extends TestCase
public function testUserStore()
{
$this->withoutMiddleware(PasswordProtection::class);
$data = [
'first_name' => 'hey',
'last_name' => 'you',
@ -88,6 +92,8 @@ class UserTest extends TestCase
public function testUserAttachAndDetach()
{
$this->withoutMiddleware(PasswordProtection::class);
$user = UserFactory::create($this->account->id);
$user->first_name = 'Test';
$user->last_name = 'Palloni';
@ -124,6 +130,7 @@ class UserTest extends TestCase
public function testAttachUserToMultipleCompanies()
{
$this->withoutMiddleware(PasswordProtection::class);
/* Create New Company */
$company2 = factory(\App\Models\Company::class)->create([