Commit d96497c9 authored by Ben's avatar Ben Committed by Mark Harding
Browse files

[Sprint/NuancedNumbat](fix): Allowing onchain boosts when offchain limit reached #1924

parent 91c223dc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -170,6 +170,11 @@ class Manager
     */
    public function isBoostLimitExceededBy($boost)
    {
        //onchain boosts allowed
        if ($boost->isOnChain()) {
            return false;
        }

        //get offchain boosts
        $offchain = $this->getOffchainBoosts($boost);
        
+24 −2
Original line number Diff line number Diff line
@@ -370,7 +370,25 @@ class ManagerSpec extends ObjectBehavior
        $this->isBoostLimitExceededBy($boost)->shouldReturn(true);
    }

    public function runThroughGetList($boost, $existingBoosts)
    public function it_should_allow_a_user_to_boost_onchain_when_offchain_limit_reached(Boost $boost)
    {
        $boostArray = [];
        for ($i = 0; $i < 2; $i++) {
            $newBoost = new Boost();
            $newBoost->setCreatedTimestamp('9999999999999999');
            $newBoost->setImpressions(5001);
            array_push($boostArray, $newBoost);
        }

        $boost->isOnChain()
            ->shouldBeCalled()
            ->willReturn(true);

        Di::_()->get('Config')->set('max_daily_boost_views', 20000);
        $this->isBoostLimitExceededBy($boost)->shouldReturn(false);
    }

    public function runThroughGetList($boost, $existingBoosts, $onchain = false)
    {
        $this->elasticRepository->getList([
            "hydrate" => true,
@@ -393,6 +411,10 @@ class ManagerSpec extends ObjectBehavior
            ->shouldBeCalled()
            ->willReturn('newsfeed');
        
        $boost->isOnChain()
            ->shouldBeCalled()
            ->willReturn($onchain);
        
        $boost->getOwnerGuid()
            ->shouldBeCalled()
            ->willReturn('123');