Skip to content

Commit

Permalink
[2.x] Change current team of user when creating a new additional team (
Browse files Browse the repository at this point in the history
…#618)

* Change current team of user when creating a new team

* Update stubs/app/Actions/Jetstream/CreateTeam.php

Co-authored-by: Joel Butcher <[email protected]>

* Update CreateTeam.php

* Fixed changes wanted by StyleCI

* Remove an unneeded test

* Update TeamBehaviorTest.php

* Update CreateTeam.php

* Attempt to fix StyleCI errors

Co-authored-by: Joel Butcher <[email protected]>
  • Loading branch information
OscarKolsrud and joelbutcher authored Jan 11, 2021
1 parent 6c226b4 commit 00f9d74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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));

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

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

0 comments on commit 00f9d74

Please sign in to comment.