Skip to content

A free open source IT asset/license management system

Moved limit

snipedb2269092a10
diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php
index 63174c0aed..726d2cb827 100644
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@ -1365,9 +1365,8 @@ class AssetsController extends Controller
}
$offset = ($request->input('offset') > $component_checkouts->count()) ? $component_checkouts->count() : app('api_offset_value');
- $limit = app('api_limit_value');
-
$total = $component_checkouts->count();
+ $limit = app('api_limit_value');
$component_checkouts = $component_checkouts->skip($offset)->take($limit)->get();
return (new AssetsTransformer)->transformCheckedoutComponents($component_checkouts, $total);
diff --git a/tests/Feature/Assets/Api/AssignedComponentsTest.php b/tests/Feature/Assets/Api/AssignedComponentsTest.php
index cfd0a16068..43a92e2cec 100644
--- a/tests/Feature/Assets/Api/AssignedComponentsTest.php
+++ b/tests/Feature/Assets/Api/AssignedComponentsTest.php
@@ -5,6 +5,7 @@ namespace Tests\Feature\Assets\Api;
use App\Models\Asset;
use App\Models\Company;
use App\Models\Component;
+use App\Models\ComponentAssignment;
use App\Models\User;
use Illuminate\Testing\Fluent\AssertableJson;
use Tests\TestCase;
@@ -55,25 +56,5 @@ class AssignedComponentsTest extends TestCase
});
}
- public function test_adheres_to_offset_and_limit()
- {
- $asset = Asset::factory()->hasComponents(2)->create();
-
- $componentsAssignedToAsset = $asset->components;
-
- $this->actingAsForApi(User::factory()->viewAssets()->create())
- ->getJson(route('api.assets.assigned_components', [
- 'asset' => $asset,
- 'offset' => 1,
- 'limit' => 1,
- ]))
- ->assertOk()
- ->assertResponseDoesNotContainInRows($componentsAssignedToAsset->first())
- ->assertResponseContainsInRows($componentsAssignedToAsset->last())
- ->assertJson(function (AssertableJson $json) {
- $json->where('total', 2)
- ->count('rows', 1)
- ->etc();
- });
- }
+
}