File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ public function switchTeam($team)
45
45
'current_team_id ' => $ team ->id ,
46
46
])->save ();
47
47
48
+ $ this ->setRelation ('currentTeam ' , $ team );
49
+
48
50
return true ;
49
51
}
50
52
Original file line number Diff line number Diff line change @@ -129,6 +129,31 @@ public function test_has_team_permission_checks_token_permissions()
129
129
$ this ->assertTrue ($ john ->hasTeamPermission ($ team , 'foo ' ));
130
130
}
131
131
132
+ public function test_user_does_not_need_to_refresh_after_switching_teams ()
133
+ {
134
+ $ this ->migrate ();
135
+
136
+ $ action = new CreateTeam ;
137
+
138
+ $ user = User::forceCreate ([
139
+ 'name ' => 'Taylor Otwell ' ,
140
+
141
+ 'password ' => 'secret ' ,
142
+ ]);
143
+
144
+ $ personalTeam = $ action ->create ($ user , ['name ' => 'Personal Team ' ]);
145
+
146
+ $ personalTeam ->forceFill (['personal_team ' => true ])->save ();
147
+
148
+ $ anotherTeam = $ action ->create ($ user , ['name ' => 'Test Team ' ]);
149
+
150
+ $ this ->assertTrue ($ user ->isCurrentTeam ($ personalTeam ));
151
+
152
+ $ user ->switchTeam ($ anotherTeam );
153
+
154
+ $ this ->assertTrue ($ user ->isCurrentTeam ($ anotherTeam ));
155
+ }
156
+
132
157
protected function migrate ()
133
158
{
134
159
$ this ->artisan ('migrate ' , ['--database ' => 'testbench ' ])->run ();
You can’t perform that action at this time.
0 commit comments