Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] Change current team of user when creating a new additional team #618

Merged
merged 8 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion stubs/app/Actions/Jetstream/CreateTeam.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ public function create($user, array $input)

AddingTeam::dispatch($user);

return $user->ownedTeams()->create([
$team = $user->ownedTeams()->create([
'name' => $input['name'],
'personal_team' => false,
]);

$user->switchTeam($team);

return $team;
}
}
4 changes: 1 addition & 3 deletions tests/TeamBehaviorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,9 @@ public function test_user_does_not_need_to_refresh_after_switching_teams()

$personalTeam->forceFill(['personal_team' => true])->save();

$anotherTeam = $action->create($user, ['name' => 'Test Team']);

$this->assertTrue($user->isCurrentTeam($personalTeam));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just move this line to before the previous line is executed?


$user->switchTeam($anotherTeam);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed now.

Suggested change
$user->switchTeam($anotherTeam);

$anotherTeam = $action->create($user, ['name' => 'Test Team']);

$this->assertTrue($user->isCurrentTeam($anotherTeam));
}
Expand Down