mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for tests
This commit is contained in:
parent
e6bc63b2c2
commit
ae8a61cbcd
@ -29,6 +29,14 @@ class StoreUserRequest extends Request
|
|||||||
|
|
||||||
public function authorize() : bool
|
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();
|
return auth()->user()->isAdmin();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,8 +51,9 @@ class StoreUserRequest extends Request
|
|||||||
$rules['email'] = new ValidUserForCompany();
|
$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);
|
$rules['hosted_users'] = new CanAddUserRule(auth()->user()->company()->account);
|
||||||
|
}
|
||||||
|
|
||||||
return $rules;
|
return $rules;
|
||||||
}
|
}
|
||||||
|
@ -196,9 +196,21 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||||||
$this->id = auth()->user()->id;
|
$this->id = auth()->user()->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
|
return $this->hasOneThrough(CompanyUser::class, CompanyToken::class, 'user_id', 'company_id', 'id', 'company_id')
|
||||||
->where('company_user.user_id', $this->id)
|
->where('company_user.user_id', $this->id)
|
||||||
->withTrashed();
|
->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();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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">
|
<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>
|
<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="#">
|
<a href="#">
|
||||||
<img class="h-8" src="{{ asset('images/invoiceninja-black-logo-2.png') }}" alt="Invoice Ninja Logo">
|
<img class="h-8" src="{{ asset('images/invoiceninja-black-logo-2.png') }}" alt="Invoice Ninja Logo">
|
||||||
</a>
|
</a>
|
||||||
|
@ -4,6 +4,7 @@ namespace Feature;
|
|||||||
|
|
||||||
use App\Factory\CompanyUserFactory;
|
use App\Factory\CompanyUserFactory;
|
||||||
use App\Factory\UserFactory;
|
use App\Factory\UserFactory;
|
||||||
|
use App\Http\Middleware\PasswordProtection;
|
||||||
use App\Models\Account;
|
use App\Models\Account;
|
||||||
use App\Models\Activity;
|
use App\Models\Activity;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
@ -35,17 +36,18 @@ class UserTest extends TestCase
|
|||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->withoutMiddleware(
|
|
||||||
ThrottleRequests::class
|
|
||||||
);
|
|
||||||
|
|
||||||
Session::start();
|
Session::start();
|
||||||
|
|
||||||
$this->faker = \Faker\Factory::create();
|
$this->faker = \Faker\Factory::create();
|
||||||
|
|
||||||
|
$this->makeTestData();
|
||||||
|
|
||||||
Model::reguard();
|
Model::reguard();
|
||||||
|
|
||||||
$this->makeTestData();
|
$this->withoutMiddleware(
|
||||||
|
ThrottleRequests::class,
|
||||||
|
PasswordProtection::class
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +64,8 @@ class UserTest extends TestCase
|
|||||||
|
|
||||||
public function testUserStore()
|
public function testUserStore()
|
||||||
{
|
{
|
||||||
|
$this->withoutMiddleware(PasswordProtection::class);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'first_name' => 'hey',
|
'first_name' => 'hey',
|
||||||
'last_name' => 'you',
|
'last_name' => 'you',
|
||||||
@ -88,6 +92,8 @@ class UserTest extends TestCase
|
|||||||
|
|
||||||
public function testUserAttachAndDetach()
|
public function testUserAttachAndDetach()
|
||||||
{
|
{
|
||||||
|
$this->withoutMiddleware(PasswordProtection::class);
|
||||||
|
|
||||||
$user = UserFactory::create($this->account->id);
|
$user = UserFactory::create($this->account->id);
|
||||||
$user->first_name = 'Test';
|
$user->first_name = 'Test';
|
||||||
$user->last_name = 'Palloni';
|
$user->last_name = 'Palloni';
|
||||||
@ -124,6 +130,7 @@ class UserTest extends TestCase
|
|||||||
|
|
||||||
public function testAttachUserToMultipleCompanies()
|
public function testAttachUserToMultipleCompanies()
|
||||||
{
|
{
|
||||||
|
$this->withoutMiddleware(PasswordProtection::class);
|
||||||
|
|
||||||
/* Create New Company */
|
/* Create New Company */
|
||||||
$company2 = factory(\App\Models\Company::class)->create([
|
$company2 = factory(\App\Models\Company::class)->create([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user