Skip to content

Commit

Permalink
Merge pull request #279 from magento-extensibility/bugfix-2.0.1
Browse files Browse the repository at this point in the history
[Extensibility] 2.0.1 bug fixes
  • Loading branch information
Korshenko, Olexii(okorshenko) committed Jan 11, 2016
2 parents f329397 + 151b768 commit e7f5b9f
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 332 deletions.
100 changes: 0 additions & 100 deletions app/code/Magento/PageCache/Model/App/FrontController/MessageBox.php

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion app/code/Magento/PageCache/etc/frontend/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<type name="Magento\Framework\App\FrontControllerInterface">
<plugin name="front-controller-builtin-cache" type="Magento\PageCache\Model\App\FrontController\BuiltinPlugin"/>
<plugin name="front-controller-varnish-cache" type="Magento\PageCache\Model\App\FrontController\VarnishPlugin"/>
<plugin name="front-controller-message-box" type="Magento\PageCache\Model\App\FrontController\MessageBox" sortOrder="0"/>
</type>
<type name="Magento\Framework\Controller\ResultInterface">
<plugin name="result-builtin-cache" type="Magento\PageCache\Model\Controller\Result\BuiltinPlugin"/>
Expand Down
26 changes: 1 addition & 25 deletions app/code/Magento/PageCache/view/frontend/web/js/page-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,6 @@ define([
return elements;
};

/**
* MsgBox Widget checks if message box is displayed and sets cookie
*/
$.widget('mage.msgBox', {
options: {
msgBoxCookieName: 'message_box_display',
msgBoxSelector: '.main div.messages'
},

/**
* Creates widget 'mage.msgBox'
* @private
*/
_create: function () {
if ($.mage.cookies.get(this.options.msgBoxCookieName)) {
$.mage.cookies.clear(this.options.msgBoxCookieName);
} else {
$(this.options.msgBoxSelector).hide();
}
}
});

/**
* FormKey Widget - this widget is generating from key, saves it to cookie and
*/
Expand Down Expand Up @@ -272,14 +250,12 @@ define([

domReady(function () {
$('body')
.msgBox()
.formKey();
});

return {
'pageCache': $.mage.pageCache,
'formKey': $.mage.formKey,
'msgBox': $.mage.msgBox
'formKey': $.mage.formKey
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,64 +64,6 @@ define([
});
});

describe('Testing msgBox Widget', function () {
var wdContainer,
msgCookieName,
msgContainer;

beforeEach(function () {
wdContainer = $('<div />');
msgContainer = $('<div />');
msgCookieName = 'FAKE_COOKIE';
});

afterEach(function () {
$(wdContainer).remove();
$(msgContainer).remove();
});

it('widget extends jQuery object', function () {
expect($.fn.msgBox).toBeDefined();
});

it('widget gets options', function () {
wdContainer.msgBox({
'msgBoxCookieName': msgCookieName
});
expect(wdContainer.msgBox('option', 'msgBoxCookieName')).toBe('FAKE_COOKIE');
});

it('widget disables cookie if it exist', function () {
spyOn($.mage.cookies, 'get').and.returnValue('FAKE_MAGE_COOKIE');
spyOn($.mage.cookies, 'clear');

wdContainer.msgBox({
'msgBoxSelector': msgContainer
});

expect($.mage.cookies.get).toHaveBeenCalled();
expect($.mage.cookies.clear).toHaveBeenCalled();
});

it('widget disables messageBox if cookie not exist', function () {
spyOn($.mage.cookies, 'get');

wdContainer.msgBox({
'msgBoxSelector': msgContainer
});

expect($.mage.cookies.get).toHaveBeenCalled();
expect(msgContainer.is(':hidden')).toBeTruthy();
});

it('widget exist on load on body', function (done) {
$(function () {
expect($('body').data('mageMsgBox')).toBeDefined();
done();
});
});
});

describe('Testing FormKey Widget', function () {
var wdContainer,
msgCookieName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function getObjectManagerConfigLoader()
*/
public function configureObjectManager(ConfigInterface $diConfig, &$sharedInstances)
{
$originalSharedInstances = $sharedInstances;
$objectManager = ObjectManager::getInstance();
$sharedInstances['Magento\Framework\ObjectManager\ConfigLoaderInterface'] = $objectManager
->get('Magento\Framework\App\ObjectManager\ConfigLoader');
Expand All @@ -80,5 +81,9 @@ public function configureObjectManager(ConfigInterface $diConfig, &$sharedInstan
$diConfig->setInterceptionConfig(
$objectManager->get('Magento\Framework\Interception\Config\Config')
);
/** Reset the shared instances once interception config is set so classes can be intercepted if necessary */
$sharedInstances = $originalSharedInstances;
$sharedInstances['Magento\Framework\ObjectManager\ConfigLoaderInterface'] = $objectManager
->get('Magento\Framework\App\ObjectManager\ConfigLoader');
}
}
Loading

0 comments on commit e7f5b9f

Please sign in to comment.