mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-26 06:04:08 -08:00
commit
b488cffc7e
|
@ -14,8 +14,9 @@ use App\Models\Asset;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\License;
|
use App\Models\License;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Auth;
|
use Auth;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
class UsersController extends Controller
|
class UsersController extends Controller
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,9 +62,7 @@ class AssetCheckoutController extends Controller
|
||||||
$admin = Auth::user();
|
$admin = Auth::user();
|
||||||
|
|
||||||
$target = $this->determineCheckoutTarget($asset);
|
$target = $this->determineCheckoutTarget($asset);
|
||||||
if ($asset->is($target)) {
|
|
||||||
throw new CheckoutNotAllowed('You cannot check an asset out to itself.');
|
|
||||||
}
|
|
||||||
$asset = $this->updateAssetLocation($asset, $target);
|
$asset = $this->updateAssetLocation($asset, $target);
|
||||||
|
|
||||||
$checkout_at = date("Y-m-d H:i:s");
|
$checkout_at = date("Y-m-d H:i:s");
|
||||||
|
|
|
@ -23,7 +23,7 @@ class AssetCheckoutRequest extends Request
|
||||||
{
|
{
|
||||||
$rules = [
|
$rules = [
|
||||||
"assigned_user" => 'required_without_all:assigned_asset,assigned_location',
|
"assigned_user" => 'required_without_all:assigned_asset,assigned_location',
|
||||||
"assigned_asset" => 'required_without_all:assigned_user,assigned_location|different:'.$this->id,
|
"assigned_asset" => 'required_without_all:assigned_user,assigned_location',
|
||||||
"assigned_location" => 'required_without_all:assigned_user,assigned_asset',
|
"assigned_location" => 'required_without_all:assigned_user,assigned_asset',
|
||||||
"checkout_to_type" => 'required|in:asset,location,user'
|
"checkout_to_type" => 'required|in:asset,location,user'
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,6 +3,7 @@ namespace App\Models;
|
||||||
|
|
||||||
use App\Events\AssetCheckedOut;
|
use App\Events\AssetCheckedOut;
|
||||||
use App\Events\CheckoutableCheckedOut;
|
use App\Events\CheckoutableCheckedOut;
|
||||||
|
use App\Exceptions\CheckoutNotAllowed;
|
||||||
use App\Http\Traits\UniqueSerialTrait;
|
use App\Http\Traits\UniqueSerialTrait;
|
||||||
use App\Http\Traits\UniqueUndeletedTrait;
|
use App\Http\Traits\UniqueUndeletedTrait;
|
||||||
use App\Models\Traits\Acceptable;
|
use App\Models\Traits\Acceptable;
|
||||||
|
@ -271,6 +272,9 @@ class Asset extends Depreciable
|
||||||
if (!$target) {
|
if (!$target) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ($this->is($target)) {
|
||||||
|
throw new CheckoutNotAllowed('You cannot check an asset out to itself.');
|
||||||
|
}
|
||||||
|
|
||||||
if ($expected_checkin) {
|
if ($expected_checkin) {
|
||||||
$this->expected_checkin = $expected_checkin;
|
$this->expected_checkin = $expected_checkin;
|
||||||
|
|
|
@ -116,7 +116,8 @@ class ApiLicensesCest
|
||||||
'category_id' => $temp_license->category_id,
|
'category_id' => $temp_license->category_id,
|
||||||
'termination_date' => $temp_license->termination_date,
|
'termination_date' => $temp_license->termination_date,
|
||||||
];
|
];
|
||||||
|
// We aren't checking anyhting out in this test, so this fakes the withCount() that happens on a normal db fetch.
|
||||||
|
$temp_license->free_seats_count = $temp_license->seats;
|
||||||
$I->assertNotEquals($license->name, $data['name']);
|
$I->assertNotEquals($license->name, $data['name']);
|
||||||
|
|
||||||
// update
|
// update
|
||||||
|
|
|
@ -65,6 +65,7 @@ class ApiUsersCest
|
||||||
'notes' => $temp_user->notes,
|
'notes' => $temp_user->notes,
|
||||||
'manager_id' => $temp_user->manager_id,
|
'manager_id' => $temp_user->manager_id,
|
||||||
'password' => $temp_user->password,
|
'password' => $temp_user->password,
|
||||||
|
'password_confirmation' => $temp_user->password,
|
||||||
'phone' => $temp_user->phone,
|
'phone' => $temp_user->phone,
|
||||||
'state' => $temp_user->state,
|
'state' => $temp_user->state,
|
||||||
'username' => $temp_user->username,
|
'username' => $temp_user->username,
|
||||||
|
|
|
@ -58,10 +58,7 @@ class GroupsCest
|
||||||
|
|
||||||
public function allowsDelete(FunctionalTester $I, $scenario)
|
public function allowsDelete(FunctionalTester $I, $scenario)
|
||||||
{
|
{
|
||||||
$scenario->incomplete('Fix this test to generate a group for deleting');
|
|
||||||
|
|
||||||
$I->wantTo('Ensure I can delete a group');
|
$I->wantTo('Ensure I can delete a group');
|
||||||
|
|
||||||
// create a group
|
// create a group
|
||||||
$I->amOnPage(route('groups.create'));
|
$I->amOnPage(route('groups.create'));
|
||||||
$I->seeResponseCodeIs(200);
|
$I->seeResponseCodeIs(200);
|
||||||
|
@ -70,16 +67,9 @@ class GroupsCest
|
||||||
$I->dontSee('<span class="');
|
$I->dontSee('<span class="');
|
||||||
$I->seeElement('.alert-success');
|
$I->seeElement('.alert-success');
|
||||||
|
|
||||||
// delete it
|
$I->sendDelete(route('groups.destroy', Group::whereName('TestGroup')->doesntHave('users')->first()->id));
|
||||||
$I->amOnPage(route('groups.delete', Group::doesntHave('users')->first()->id));
|
|
||||||
$I->seeResponseCodeIs(200);
|
$I->seeResponseCodeIs(200);
|
||||||
$I->seeElement('.alert-success');
|
$I->seeElement('.alert-success');
|
||||||
// $I->seeResponseCodeIs(200);
|
$I->seeResponseCodeIs(200);
|
||||||
}
|
|
||||||
|
|
||||||
public function allowsEditing(FunctionalTester $I, $scenario)
|
|
||||||
{
|
|
||||||
$scenario->incomplete('Fix this test to generate a group for editing');
|
|
||||||
$I->wantTo('Ensure i can edit a group');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -287,6 +287,11 @@ class AssetTest extends BaseTest
|
||||||
'target_id' => $target->id
|
'target_id' => $target->id
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// An Asset cannot be checked out to itself.
|
||||||
|
$target = $this->createValidAsset();
|
||||||
|
$this->expectException(CheckoutNotAllowed::class);
|
||||||
|
$target->checkOut($target, $adminUser);
|
||||||
|
|
||||||
// An Asset Can be checked out to a location, and this should be logged.
|
// An Asset Can be checked out to a location, and this should be logged.
|
||||||
$target = $this->createValidLocation();
|
$target = $this->createValidLocation();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue