Compare commits

...

2 Commits

Author SHA1 Message Date
philipp lang 300e935a92 Fix UpdateTest
continuous-integration/drone/push Build is failing Details
2024-08-28 22:31:35 +02:00
philipp lang a74732a22b Fix member links 2024-08-28 22:28:12 +02:00
4 changed files with 27 additions and 36 deletions

View File

@ -4,6 +4,7 @@ namespace App\Member;
use App\Http\Controllers\Controller;
use App\Setting\NamiSettings;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Inertia\Response;
@ -34,14 +35,14 @@ class MemberController extends Controller
return redirect()->route('member.index');
}
public function update(Member $member, MemberRequest $request): RedirectResponse
public function update(Member $member, MemberRequest $request): JsonResponse
{
try {
$request->persistUpdate($member);
} catch (ConflictException $e) {
return redirect()->route('member.edit', ['member' => $member, 'conflict' => '1']);
return response()->json([], 409);
}
return redirect()->route('member.index');
return response()->json([]);
}
}

View File

@ -111,7 +111,7 @@ class MemberResource extends JsonResource
'invoiceposition_index' => route('member.invoice-position.index', ['member' => $this->getModel()]),
'course_index' => route('member.course.index', ['member' => $this->getModel()]),
'show' => route('member.show', ['member' => $this->getModel()]),
'edit' => route('member.edit', ['member' => $this->getModel()]),
'update' => route('member.update', ['member' => $this->getModel()]),
],
];
}
@ -155,7 +155,6 @@ class MemberResource extends JsonResource
'members' => Member::ordered()->get()->map(fn ($member) => ['id' => $member->id, 'name' => $member->fullname]),
'links' => [
'index' => route('member.index'),
'create' => route('member.create'),
],
'default_membership_filter' => [
'group_ids' => [],

View File

@ -128,7 +128,8 @@ class ShowTest extends TestCase
->assertJsonPath('data.courses.0.course.short_name', '2e')
->assertJsonPath('data.invoicePositions.0.description', 'uu')
->assertJsonPath('data.invoicePositions.0.price_human', '10,50 €')
->assertJsonPath('data.invoicePositions.0.invoice.status', 'Neu');
->assertJsonPath('data.invoicePositions.0.invoice.status', 'Neu')
->assertJsonPath('data.links.update', route('member.update', ['member' => $member]));
}
public function testItShowsMinimalSingleMember(): void

View File

@ -30,11 +30,8 @@ class UpdateTest extends TestCase
$this->fakeRequest();
NamiPutMemberAction::allowToRun();
$response = $this
->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true]));
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true]));
$response->assertRedirect('/member');
NamiPutMemberAction::spy()->shouldHaveReceived('handle')->withArgs(
fn (Member $memberParam, ?Activity $activityParam, ?Subactivity $subactivityParam) => $memberParam->is($member)
&& null === $activityParam
@ -49,11 +46,8 @@ class UpdateTest extends TestCase
$member->update(['version' => 43]);
$this->fakeRequest();
$response = $this
->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::']));
$response->assertRedirect("/member/{$member->id}/edit?conflict=1");
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), ['has_nami' => true, 'firstname' => '::firstname::']))
->assertStatus(409);
}
public function testItUpdatesPhoneNumber(): void
@ -99,11 +93,9 @@ class UpdateTest extends TestCase
$member = $this->member(['nami_id' => null]);
$this->fakeRequest();
$response = $this
->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
'other_country' => 'englisch',
]));
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
'other_country' => 'englisch',
]));
$this->assertEquals('englisch', $member->fresh()->other_country);
}
@ -158,22 +150,20 @@ class UpdateTest extends TestCase
$member = $this->member(['nami_id' => null]);
$this->fakeRequest();
$response = $this
->from("/member/{$member->id}")
->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
'ps_at' => '2021-02-01',
'more_ps_at' => '2021-02-02',
'has_svk' => true,
'has_vk' => true,
'efz' => '2021-02-03',
'without_education_at' => '2021-02-04',
'without_efz_at' => '2021-02-05',
'recertified_at' => '2021-02-08',
'has_nami' => false,
'multiply_pv' => true,
'multiply_more_pv' => true,
'salutation' => 'Doktor',
]));
$this->patch("/member/{$member->id}", array_merge($member->getAttributes(), [
'ps_at' => '2021-02-01',
'more_ps_at' => '2021-02-02',
'has_svk' => true,
'has_vk' => true,
'efz' => '2021-02-03',
'without_education_at' => '2021-02-04',
'without_efz_at' => '2021-02-05',
'recertified_at' => '2021-02-08',
'has_nami' => false,
'multiply_pv' => true,
'multiply_more_pv' => true,
'salutation' => 'Doktor',
]));
$this->assertEquals('2021-02-01', $member->fresh()->ps_at->format('Y-m-d'));
$this->assertEquals('2021-02-02', $member->fresh()->more_ps_at->format('Y-m-d'));