mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
Bulk action tests for group settings
This commit is contained in:
parent
0dbfd0ccf0
commit
6834ada604
@ -179,9 +179,9 @@ class GroupSettingController extends BaseController
|
|||||||
|
|
||||||
$ids = request()->input('ids');
|
$ids = request()->input('ids');
|
||||||
|
|
||||||
$group_settings = GroupSetting::withTrashed()->whereIn('id', $this->transformKeys($ids))->company()->get();
|
$group_settings = GroupSetting::withTrashed()->whereIn('id', $this->transformKeys($ids))->company();
|
||||||
|
|
||||||
if (! $group_settings) {
|
if ($group_settings->count() == 0) {
|
||||||
return response()->json(['message' => ctrans('texts.no_group_settings_found')]);
|
return response()->json(['message' => ctrans('texts.no_group_settings_found')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ class GroupSettingController extends BaseController
|
|||||||
/*
|
/*
|
||||||
* Send the other actions to the switch
|
* Send the other actions to the switch
|
||||||
*/
|
*/
|
||||||
$group_settings->each(function ($group, $key) use ($action, $user) {
|
$group_settings->cursor()->each(function ($group, $key) use ($action, $user) {
|
||||||
if ($user->can('edit', $group)) {
|
if ($user->can('edit', $group)) {
|
||||||
$this->group_setting_repo->{$action}($group);
|
$this->group_setting_repo->{$action}($group);
|
||||||
}
|
}
|
||||||
|
@ -116,10 +116,13 @@ class GroupSettingTest extends TestCase
|
|||||||
$response->assertStatus(200);
|
$response->assertStatus(200);
|
||||||
|
|
||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
|
$id = $arr['data']['id'];
|
||||||
|
|
||||||
|
$this->assertEquals(0, $arr['data']['archived_at']);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'action' => 'archive',
|
'action' => 'archive',
|
||||||
'ids' => [$arr['data']['id']],
|
'ids' => [$id],
|
||||||
];
|
];
|
||||||
|
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
@ -132,5 +135,41 @@ class GroupSettingTest extends TestCase
|
|||||||
$arr = $response->json();
|
$arr = $response->json();
|
||||||
|
|
||||||
$this->assertNotNull($arr['data'][0]['archived_at']);
|
$this->assertNotNull($arr['data'][0]['archived_at']);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'action' => 'restore',
|
||||||
|
'ids' => [$id],
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->postJson('/api/v1/group_settings/bulk', $data);
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
|
|
||||||
|
$this->assertEquals(0, $arr['data'][0]['archived_at']);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'action' => 'delete',
|
||||||
|
'ids' => [$id],
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->postJson('/api/v1/group_settings/bulk', $data);
|
||||||
|
|
||||||
|
$response->assertStatus(200);
|
||||||
|
|
||||||
|
$arr = $response->json();
|
||||||
|
|
||||||
|
$this->assertNotNull($arr['data'][0]['archived_at']);
|
||||||
|
$this->assertTrue($arr['data'][0]['is_deleted']);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user