forked from opencomponents/oc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for Custom cache headers of one component can appear to another.
The problem was introduced with opencomponents#326 - In get-component.js the declaration of responseHeaders var happens in a more global scope than it should be. For this reason every invocation of renderer function sees the changes in the headers made by previously requested components. The fix is to just move the declaration one scope inner. - Added a unit test to validate the fix - it tries to load two components subsequently. The first one does provide custom headers while the second one - don't. Then we check and expect to see there are no custom headers in the result for the second one.
- Loading branch information
1 parent
0dac67e
commit b685780
Showing
5 changed files
with
160 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
test/fixtures/mocked-components/another-response-headers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
package: { | ||
name: 'response-headers-2-component', | ||
version: '1.0.0', | ||
oc: { | ||
container: false, | ||
renderInfo: false, | ||
files: { | ||
template: { | ||
type: 'jade', | ||
hashKey: '8c1fbd954f2b0d8cd5cf11c885fed4805225749f', | ||
src: 'template.js' | ||
}, | ||
dataProvider: { | ||
type: 'node.js', | ||
hashKey: '123456', | ||
src: 'server.js' | ||
} | ||
} | ||
} | ||
}, | ||
data: '"use strict";module.exports.data = function(ctx, cb){ctx.setHeader("another-test-header","another-test-value"); cb(null, {done:true});};', | ||
view: 'var oc=oc||{};oc.components=oc.components||{},oc.components["8c1fbd954f2b0d8cd5cf11c885fed4805225749f"]' + | ||
'=function(){var o=[];return o.push("<div>hello</div>"),o.join("")};' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
|
||
module.exports = { | ||
package: { | ||
name: 'simple-component', | ||
version: '1.0.0', | ||
oc: { | ||
container: false, | ||
renderInfo: false, | ||
files: { | ||
template: { | ||
type: 'jade', | ||
hashKey: '8c1fbd954f2b0d8cd5cf11c885fed4805225749f', | ||
src: 'template.js' | ||
}, | ||
dataProvider: { | ||
type: 'node.js', | ||
hashKey: '123457', | ||
src: 'server.js' | ||
} | ||
} | ||
} | ||
}, | ||
data: '"use strict";module.exports.data = function(ctx, cb){cb(null, {done:true});};', | ||
view: 'var oc=oc||{};oc.components=oc.components||{},oc.components["8c1fbd954f2b0d8cd5cf11c885fed4805225749f"]' + | ||
'=function(){var o=[];return o.push("<div>hello</div>"),o.join("")};' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters