Skip to content

Commit c102550

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-59135' into BUGS
2 parents 02a586c + 2b47ff4 commit c102550

File tree

5 files changed

+28
-22
lines changed

5 files changed

+28
-22
lines changed

app/code/Magento/Customer/view/frontend/templates/js/customer-data/invalidation-rules.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
'website-rule' => [
1919
'Magento_Customer/js/invalidation-rules/website-rule' => [
2020
'scopeConfig' => [
21-
'website_id' => $block->getWebsiteId(),
21+
'websiteId' => $block->getWebsiteId(),
2222
]
2323
]
2424
]

app/code/Magento/Customer/view/frontend/web/js/customer-data.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ define([
214214
this.reload(storageInvalidation.keys(), false);
215215
}
216216
}
217+
217218
if (!_.isEmpty(privateContent)) {
218219
countryData = this.get('directory-data');
219220

app/code/Magento/Customer/view/frontend/web/js/invalidation-processor.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
* See COPYING.txt for license details.
44
*/
55
define([
6-
"underscore",
7-
"uiElement",
6+
'underscore',
7+
'uiElement',
88
'Magento_Customer/js/customer-data'
99
], function (_, Element, customerData) {
10-
"use strict";
11-
var invalidationRules;
10+
'use strict';
1211

1312
return Element.extend({
13+
/**
14+
* Initialize object
15+
*/
1416
initialize: function () {
1517
this._super();
1618
this.process(customerData);
@@ -19,17 +21,18 @@ define([
1921
/**
2022
* Process all rules in loop, each rule can invalidate some sections in customer data
2123
*
22-
* @param {Object} customerData
24+
* @param {Object} customerDataObject
2325
*/
24-
process: function (customerData) {
26+
process: function (customerDataObject) {
2527
_.each(this.invalidationRules, function (rule, ruleName) {
2628
_.each(rule, function (ruleArgs, rulePath) {
2729
require([rulePath], function (Rule) {
28-
var rule = new Rule(ruleArgs);
29-
if (!_.isFunction(rule.process)) {
30-
throw new Error("Rule " + ruleName + " should implement invalidationProcessor interface");
30+
var currentRule = new Rule(ruleArgs);
31+
32+
if (!_.isFunction(currentRule.process)) {
33+
throw new Error('Rule ' + ruleName + ' should implement invalidationProcessor interface');
3134
}
32-
rule.process(customerData);
35+
currentRule.process(customerDataObject);
3336
});
3437
});
3538
});

app/code/Magento/Customer/view/frontend/web/js/invalidation-rules/website-rule.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* See COPYING.txt for license details.
44
*/
55
define([
6-
"uiClass"
6+
'uiClass'
77
], function (Element) {
88
'use strict';
99

@@ -12,7 +12,7 @@ define([
1212
defaults: {
1313
scopeConfig: {}
1414
},
15-
15+
1616
/**
1717
* Takes website id from current customer data and compare it with current website id
1818
* If customer belongs to another scope, we need to invalidate current section
@@ -22,7 +22,7 @@ define([
2222
process: function (customerData) {
2323
var customer = customerData.get('customer');
2424

25-
if (this.scopeConfig && customer() && customer().websiteId != this.scopeConfig.website_id) {
25+
if (this.scopeConfig && customer() && customer().websiteId !== this.scopeConfig.websiteId) {
2626
customerData.reload(['customer']);
2727
}
2828
}

dev/tests/js/jasmine/tests/app/code/Magento/Customer/frontend/js/invalidation-processor.test.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable max-nested-callbacks */
12
define([
23
'squire'
34
], function (Squire) {
@@ -17,6 +18,13 @@ define([
1718
processor = new Constr({
1819
name: 'processor'
1920
});
21+
processor.invalidationRules = {
22+
'website-rule': {
23+
'Magento_Customer/js/invalidation-rules/website-rule': {
24+
process: jasmine.createSpy()
25+
}
26+
}
27+
};
2028
done();
2129
});
2230
});
@@ -25,15 +33,9 @@ define([
2533

2634
describe('"process" method', function () {
2735
it('record status is 1', function () {
28-
var requireTmp = require;
36+
/* eslint-disable no-native-reassign */
2937

30-
processor.invalidationRules = {
31-
'website-rule': {
32-
'Magento_Customer/js/invalidation-rules/website-rule': {
33-
process: jasmine.createSpy()
34-
}
35-
}
36-
};
38+
var requireTmp = require;
3739

3840
require = jasmine.createSpy();
3941
processor.process();

0 commit comments

Comments
 (0)