Skip to content

Commit

Permalink
Fix enabled option
Browse files Browse the repository at this point in the history
  • Loading branch information
Anahkiasen committed Nov 21, 2014
1 parent 525563e commit 1be3b44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/Flatten/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,10 @@ public function shouldCachePage()
*/
public function isInAllowedEnvironment()
{
if (!$this->app->bound('env')) {
return true;
}

// Get allowed environments
$allowedEnvs = (array) $this->app['config']->get('flatten::environments');
$allowed = (boolean) $this->app['config']->get('flatten::enabled');

return !$this->inConsole && !in_array($this->app['env'], $allowedEnvs);
return !$this->inConsole && $allowed;
}

/**
Expand Down
9 changes: 3 additions & 6 deletions tests/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,11 @@ public function testCanUncacheAllPagesWithIgnore()
public function testCanCheckIfInAllowedEnvironment()
{
$this->app['config'] = $this->mockConfig();
$this->app['config']->shouldReceive('get')->with('flatten::environments')->andReturn(array('local'));

$this->assertTrue($this->context->isInAllowedEnvironment());

$this->app['env'] = 'production';
$this->app['config']->shouldReceive('get')->with('flatten::enabled')->andReturn(true);
$this->assertTrue($this->context->isInAllowedEnvironment());

$this->app['env'] = 'local';
$this->app['config'] = $this->mockConfig();
$this->app['config']->shouldReceive('get')->with('flatten::enabled')->andReturn(false);
$this->assertFalse($this->context->isInAllowedEnvironment());
}

Expand Down

0 comments on commit 1be3b44

Please sign in to comment.