Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Commit

Permalink
#89 - fix wrong admin invitation receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
Anna-Sokolowska committed May 11, 2022
1 parent d6cd834 commit 56b5dfd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/Services/InvitationsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@

use Blumilk\Meetup\Core\Models\User;
use Blumilk\Meetup\Core\Notifications\InvitationEmailNotification;
use Illuminate\Support\Facades\Notification;

class InvitationsService
{
public function sendInvitation(User $senderUser, string $email): void
{
$senderUser->notify(new InvitationEmailNotification($senderUser, $email));
Notification::route("mail", $email)->notify(new InvitationEmailNotification($senderUser, $email));
}
}
13 changes: 7 additions & 6 deletions tests/Feature/InviteAdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ public function testAdminCanSendInvitation(): void
{
Notification::fake();

$invitedUser = User::factory([
"email" => "[email protected]",
])->make();

$this->actingAs($this->admin)
->post("/invitation", [
"email" => $invitedUser->email,
"email" => "[email protected]"
])
->assertSessionHasNoErrors();

Notification::assertSentTo($invitedUser, InvitationEmailNotification::class);
Notification::assertSentOnDemand(
InvitationEmailNotification::class,
function ($notification, $channels, $notifiable) {
return $notifiable->routes['mail'] === '[email protected]';
}
);
}

public function testUserCannotSendInvitation(): void
Expand Down

0 comments on commit 56b5dfd

Please sign in to comment.