Fix gravatar url check
This commit is contained in:
parent
62cea3eb0c
commit
eafea01e22
@ -15,7 +15,7 @@ class User extends Resource
|
||||
$res = [
|
||||
'id' => $this->id,
|
||||
'pilot_id' => $this->pilot_id,
|
||||
'avatar' => $this->avatar,
|
||||
'avatar' => $this->avatar->url,
|
||||
'ident' => $this->ident,
|
||||
'name' => $this->name,
|
||||
'email' => $this->email,
|
||||
|
@ -143,7 +143,9 @@ class User extends Authenticatable
|
||||
public function getAvatarAttribute()
|
||||
{
|
||||
if (!$this->attributes['avatar']) {
|
||||
return $this->gravatar();
|
||||
return new File([
|
||||
'path' => $this->gravatar(),
|
||||
]);
|
||||
}
|
||||
|
||||
return new File([
|
||||
|
@ -266,9 +266,22 @@ class ApiTest extends TestCase
|
||||
|
||||
public function testGetUser()
|
||||
{
|
||||
$this->user = factory(App\Models\User::class)->create();
|
||||
$this->user = factory(App\Models\User::class)->create([
|
||||
'avatar' => '/assets/avatar.jpg',
|
||||
]);
|
||||
|
||||
$res = $this->get('/api/user')->assertStatus(200);
|
||||
$user = $res->json('data');
|
||||
$this->assertNotNull($user);
|
||||
$this->assertTrue(strpos($user['avatar'], 'http') !== -1);
|
||||
|
||||
// Should go to gravatar
|
||||
|
||||
$this->user = factory(App\Models\User::class)->create();
|
||||
|
||||
$res = $this->get('/api/user')->assertStatus(200);
|
||||
$user = $res->json('data');
|
||||
$this->assertNotNull($user);
|
||||
$this->assertTrue(strpos($user['avatar'], 'gravatar') !== -1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user