Commit 2659fb93 authored by Brian Hatchet's avatar Brian Hatchet :speech_balloon:

Fixing rate limit unit test that was time dependent

1 merge request!335Feat/permissions on entities 737
Pipeline #84182315 passed with stages
in 9 minutes and 34 seconds
......@@ -101,9 +101,10 @@ class Manager
* Impose the rate limit
* @return void
*/
public function impose()
public function impose($time = null)
{
$this->user->set($this->key, time() + $this->limitLength);
$time = $time ?: time();
$this->user->set($this->key, $time + $this->limitLength);
$this->user->save(); //TODO: update to new repo system soon
//Send a notification
......
......@@ -53,7 +53,8 @@ class ManagerSpec extends ObjectBehavior
public function it_should_impose_a_rate_limit_with_a_custom_limit_period(User $user)
{
$user->set('ratelimited_interaction:subscribe', time() + 600)
$time = time();
$user->set('ratelimited_interaction:subscribe', $time + 600)
->shouldBeCalled();
$user->save()
......@@ -68,7 +69,7 @@ class ManagerSpec extends ObjectBehavior
$this->setUser($user)
->setInteraction('subscribe')
->setLimitLength(600)//10 minutes
->impose();
->impose($time);
}
public function it_should_return_false_if_no_rate_limit(User $user)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment