Skip to content

Commit

Permalink
feat: disable fieldsets by default (#262)
Browse files Browse the repository at this point in the history
* feat: disable fieldsets by default

* test: take new changes into account
  • Loading branch information
Mohammad-Alavi authored Dec 16, 2024
1 parent 5312936 commit 10571be
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/fractal.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
*
* NOTE: This feature does not work if the "resource name" is not set.
*/
'enabled' => true,
'enabled' => false,

/*
* The name of key in the request, where we should look for the fieldsets to parse.
Expand Down
4 changes: 4 additions & 0 deletions tests/AutoFieldsetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use Illuminate\Testing\Fluent\AssertableJson;

it('returns only requested fields', function ($fields, $expectedMissing) {
config()->set('fractal.auto_fieldsets.enabled', true);
$response = $this->call('GET', '/auto-fieldsets-with-resource-name', [
'fields' => [
'books' => $fields,
Expand All @@ -27,6 +28,7 @@
]);

it('doesnt work if "resource name" is not set', function ($fields) {
config()->set('fractal.auto_fieldsets.enabled', true);
$response = $this->call('GET', '/auto-fieldsets-without-resource-name', [
'fields' => [
'books' => $fields,
Expand All @@ -50,6 +52,7 @@
]);

it('all fields are present when parameter is not passed', function () {
config()->set('fractal.auto_fieldsets.enabled', true);
$response = $this->call('GET', '/auto-fieldsets-with-resource-name', [
'include' => 'characters',
]);
Expand Down Expand Up @@ -86,6 +89,7 @@
});

it('uses the configured request key', function () {
config()->set('fractal.auto_fieldsets.enabled', true);
config()->set('fractal.auto_fieldsets.request_key', 'other_fields');
$response = $this->call('GET', '/auto-fieldsets-with-resource-name', [
'fields' => [
Expand Down

0 comments on commit 10571be

Please sign in to comment.