Fix: Store membership for non nami member
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
aa81843df1
commit
594c45aede
|
@ -33,7 +33,7 @@ class MembershipStoreAction
|
||||||
|
|
||||||
$subactivity = $subactivity ?: new Subactivity(['nami_id' => null, 'id' => null]);
|
$subactivity = $subactivity ?: new Subactivity(['nami_id' => null, 'id' => null]);
|
||||||
|
|
||||||
if ($activity->hasNami && ($subactivity->id === null || $subactivity->hasNami)) {
|
if ($this->syncable($member, $activity, $subactivity)) {
|
||||||
try {
|
try {
|
||||||
$namiId = app(NamiSettings::class)->login()->putMembership($member->nami_id, NamiMembership::from([
|
$namiId = app(NamiSettings::class)->login()->putMembership($member->nami_id, NamiMembership::from([
|
||||||
'startsAt' => $from,
|
'startsAt' => $from,
|
||||||
|
@ -55,7 +55,7 @@ class MembershipStoreAction
|
||||||
'nami_id' => $namiId ?? null,
|
'nami_id' => $namiId ?? null,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($activity->hasNami && ($subactivity->id === null || $subactivity->hasNami)) {
|
if ($this->syncable($member, $activity, $subactivity)) {
|
||||||
$member->syncVersion();
|
$member->syncVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,11 @@ class MembershipStoreAction
|
||||||
return $membership;
|
return $membership;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function syncable(Member $member, Activity $activity, ?Subactivity $subactivity): bool
|
||||||
|
{
|
||||||
|
return $activity->hasNami && ($subactivity->id === null || $subactivity->hasNami) && $member->hasNami;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array<string, array<int, string|In>>
|
* @return array<string, array<int, string|In>>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -247,6 +247,18 @@ class StoreTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testItStoresNamiActivityAndSubactivityForNonNamiMember(): void
|
||||||
|
{
|
||||||
|
$this->withoutExceptionHandling();
|
||||||
|
$member = Member::factory()->defaults()->create();
|
||||||
|
$activity = Activity::factory()->hasAttached(Subactivity::factory()->inNami(7))->inNami(6)->create();
|
||||||
|
|
||||||
|
$this->post(
|
||||||
|
"/member/{$member->id}/membership",
|
||||||
|
MembershipRequestFactory::new()->in($activity, $activity->subactivities->first())->group($member->group)->create()
|
||||||
|
)->assertOk();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @testWith ["namierror<br>", "namierror<br>"]
|
* @testWith ["namierror<br>", "namierror<br>"]
|
||||||
* ["", "Erstellen der Mitgliedschaft fehlgeschlagen"]
|
* ["", "Erstellen der Mitgliedschaft fehlgeschlagen"]
|
||||||
|
|
Loading…
Reference in New Issue