diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 9f52f8f7..9a83d085 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -69,11 +69,6 @@ class UserController extends Controller */ public function sign() { - // Hacking for testing - if (config('app.env') == 'testing') { - $this->user = User::find($this->user->uid); - } - if ($this->user->canSign()) { $acquiredScore = $this->user->sign(); diff --git a/tests/UserControllerTest.php b/tests/UserControllerTest.php index 147c8e2d..7920243b 100644 --- a/tests/UserControllerTest.php +++ b/tests/UserControllerTest.php @@ -88,9 +88,10 @@ class UserControllerTest extends TestCase ) ]); - $user->last_sign_at = \Carbon\Carbon::today()->toDateTimeString(); - $user->save(); - $this->postJson('/user/sign') + $user = factory(User::class)->create([ + 'last_sign_at' => \Carbon\Carbon::today()->toDateTimeString() + ]); + $this->actAs($user)->postJson('/user/sign') ->assertJson([ 'errno' => 0 ]);