fixed several column changes found by tests

This commit is contained in:
Daniel Klabbers 2018-05-14 11:34:24 +02:00
parent 7539c25048
commit fd859e33be
6 changed files with 12 additions and 9 deletions

View File

@ -399,7 +399,7 @@ class Discussion extends AbstractModel
*/
public function readers()
{
return $this->belongsToMany(User::class, 'users_discussions');
return $this->belongsToMany(User::class, 'discussions_users');
}
/**

View File

@ -50,6 +50,6 @@ class Floodgate
new CheckingForFlooding($actor)
);
return $isFlooding ?? Post::where('user_id', $actor->id)->where('time', '>=', new DateTime('-10 seconds'))->exists();
return $isFlooding ?? Post::where('user_id', $actor->id)->where('created_at', '>=', new DateTime('-10 seconds'))->exists();
}
}

View File

@ -16,7 +16,10 @@ use Flarum\Database\AbstractModel;
use Flarum\User\Exception\InvalidConfirmationTokenException;
/**
* @todo document database columns with @property
* @property string $token
* @property int $user_id
* @property \Carbon\Carbon $created_at
* @property string $email
*/
class EmailToken extends AbstractModel
{
@ -49,7 +52,7 @@ class EmailToken extends AbstractModel
{
$token = new static;
$token->id = str_random(40);
$token->token = str_random(40);
$token->user_id = $userId;
$token->email = $email;
$token->created_at = time();

View File

@ -50,8 +50,8 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
* @property \Carbon\Carbon|null $last_seen_at
* @property \Carbon\Carbon|null $marked_all_as_read_at
* @property \Carbon\Carbon|null $read_notifications_at
* @property int $discussions_count
* @property int $comments_count
* @property int $discussion_count
* @property int $comment_count
*/
class User extends AbstractModel
{

View File

@ -93,7 +93,7 @@ class UserMetadataUpdater
$user = $post->user;
if ($user && $user->exists) {
$user->comments_count += $amount;
$user->comment_count += $amount;
$user->save();
}
}
@ -107,7 +107,7 @@ class UserMetadataUpdater
$user = $discussion->startUser;
if ($user && $user->exists) {
$user->discussions_count += $amount;
$user->discussion_count += $amount;
$user->save();
}
}

View File

@ -74,7 +74,7 @@ class CreateUserControllerTest extends ApiControllerTestCase
/** @var User $user */
$user = User::where('username', 'test')->firstOrFail();
$this->assertEquals(1, $user->is_activated);
$this->assertEquals(1, $user->is_email_confirmed);
}
/**