Commit d6f22dc0 authored by Ghislain Loas's avatar Ghislain Loas

dev #58111 stopTracking when visiting new features

parent 5e8c4217
......@@ -23,6 +23,7 @@
class Admin_FeatureController extends ZendAfi_Controller_Action {
public function indexAction() {
$this->view->titre = $this->_('Les fonctionnalités du logiciel Bokeh');
(new Class_Feature())->stopTracking();
$user = Class_Users::getIdentity();
$this->view->new_features = (new Class_Feature)->findNewFor($user);
$this->view->checked_features = (new Class_Feature)->findCheckedBy($user);
......
......@@ -188,12 +188,21 @@ class Class_Feature {
public function stopTracking() {
if (!Class_AdminVar::get('FEATURES_TRACKING_ENABLE'))
return;
if(!$user = Class_Users::getIdentity())
return;
if(!$user->isAdmin())
return;
$this->_getCookieJar()->getKey();
$this->_session = new Zend_Session_Namespace($this->_getCookieJar()->getKey());
return $this->_getCookieJar()
->setcookie($this->_getCookieJar()->getKey(),
'1',
$this->getTimeSource()->time() + (3600 * 24 * 30 * 6));
$this->getTimeSource()->time() + (3600 * 24 * 30 * 3));
}
}
......
......@@ -39,12 +39,10 @@ abstract class IndexControllerFeaturesTrackingTestCase extends Admin_AbstractCon
Class_Feature::setCookieJar($this->_cookie_jar =
$this->mock()
->whenCalled('setcookie')
->answers(null)
->answers(true)
->whenCalled('getKey')
->answers('tracking_features_7_11_20')
->beStrict());
->answers('tracking_features_7_11_20'));
}
......@@ -128,10 +126,15 @@ class IndexControllerFeaturesTrackingExistingCookieVisitTest
extends IndexControllerFeaturesTrackingTestCase {
public function setUp() {
parent::setUp();
$_COOKIE['tracking_features_7_11_20'] = 1;
$this->dispatch('/', true);
}
/** @test */
public function shouldNotDisplayNewFeaturesMessage() {
$_COOKIE['tracking_features_' . BOKEH_RELEASE_NUMBER] = 1;
$this->dispatch('/', true);
$this->assertNotXPathContentContains('//script', $this->_expected_message);
}
}
......@@ -148,24 +151,24 @@ class IndexControllerFeaturesTrackingUntrackTest
->whenCalled('setcookie')
->with('tracking_features_7_11_20',
1,
1534762314)
->answers($_COOKIE = ['tracking_features_7_11_20' => 1])
1526986314)
->answers(true)
->whenCalled('getKey')
->answers('tracking_features_7_11_20'));
$this->dispatch('/admin/feature/stop-tracking', true);
}
/** @test */
public function shouldNotDisplayNewFeaturesMessage() {
$this->assertEquals(1, $_COOKIE['tracking_features_7_11_20']);
public function stopTrackingActionshouldSetCookie() {
$this->dispatch('/admin/feature/stop-tracking', true);
$this->assertTrue($this->_cookie_jar->methodHasBeenCalled('setcookie'));
}
/** @test */
public function shouldSetCookie() {
public function indexActionSetCookie() {
$this->dispatch('/admin/feature/index', true);
$this->assertTrue($this->_cookie_jar->methodHasBeenCalled('setcookie'));
}
}
\ No newline at end of file
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