Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1009 from caridy/redirect-issue-293
Browse files Browse the repository at this point in the history
Fixed issue #293. HTMLFrameMojit should honor child metas, including ac.http.redirect() related metas.
  • Loading branch information
caridy committed Feb 25, 2013
2 parents 3d54d76 + bee4758 commit 21c566a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 9 deletions.
15 changes: 9 additions & 6 deletions lib/app/mojits/HTMLFrameMojit/controller.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ YUI.add('HTMLFrameMojit', function (Y, NAME) {
meta.binders);
}

// we don't care much about the views specified in childs
// and for the parent, we have a fixed one.
meta.view = {
name: 'index'
};

// 1. mixing bottom and top fragments from assets into
// the template data, along with title and mojito version.
// 2. mixing meta with child metas, along with some extra
Expand All @@ -43,19 +49,15 @@ YUI.add('HTMLFrameMojit', function (Y, NAME) {
mojito_version: Y.mojito.version

}),
Y.merge(meta, {
Y.mojito.util.metaMerge(meta, {

http: {
headers: {
'content-type': 'text/html; charset="utf-8"'
}
},

view: {
name: 'index'
}

})
}, true)
);

});
Expand Down Expand Up @@ -96,6 +98,7 @@ YUI.add('HTMLFrameMojit', function (Y, NAME) {

}, '0.1.0', {requires: [
'mojito',
'mojito-util',
'mojito-assets-addon',
'mojito-deploy-addon',
'mojito-config-addon',
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/app/mojits/mojits_test_descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dataprovider" : {
"htmlframemojit-controller": {
"params": {
"lib": "$$config.lib$$/app/mojits/HTMLFrameMojit/controller.server.js",
"lib": "$$config.lib$$/app/mojits/HTMLFrameMojit/controller.server.js,./../../../../../lib/app/autoload/util.common.js",
"test": "./test-htmlframemojit-controller.server.js",
"driver": "nodejs"
},
Expand Down
61 changes: 59 additions & 2 deletions tests/unit/lib/app/mojits/test-htmlframemojit-controller.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ YUI().use('HTMLFrameMojit', 'test', function(Y, NAME) {
cfg: cfg
};
callback({}, {
metaFromChildGoesHere: true,
assets: {
bottom: {}
}
Expand Down Expand Up @@ -166,11 +165,69 @@ YUI().use('HTMLFrameMojit', 'test', function(Y, NAME) {

A.isString(doneCalled.data.title, 'title is required');

A.isTrue(doneCalled.viewMeta.metaFromChildGoesHere, 'meta should be passed into done');
A.areEqual('index', doneCalled.viewMeta.view.name, 'the view name should always be index');

A.isObject(assetsAdded, 'ac.assets.addAssets was not called');
A.isObject(doneCalled.viewMeta.assets.bottom, 'assets coming from the child should be inserted in the correct position');
},

'test metas edge cases': function() {

var dispatchCalled,
doneCalled,
executeCalled,
assetsAdded,
ac = {
config: {
get: function (name) {
return {
child: {
base: "child-1"
},
assets: {},
deploy: false
}[name];
}
},
composite: {
execute: function (cfg, callback) {
callback({}, {
view: {
name: "trying-to-overrule-parent-view"
},
http: {
headers: {
'content-type': 'trying-to-overrule-parent-content-type',
'something-extra': 1
}
},
metaFromChildGoesHere: true
});
}
},
done: function(data, viewMeta) {
doneCalled = {
data: data,
viewMeta: viewMeta
};
},
assets: {
renderLocations: function() {
return {};
},
getAssets: function() {
return [];
},
addAssets: function(assets) {
}
}
};

Y.mojito.controllers.HTMLFrameMojit.index(ac);
A.isTrue(doneCalled.viewMeta.metaFromChildGoesHere, 'custom meta should be passed into done');
A.areEqual('index', doneCalled.viewMeta.view.name, 'the view name should always be index');
A.areEqual(1, doneCalled.viewMeta.http.headers['something-extra'], 'extra headers from children should be mixed in');
A.areEqual('text/html; charset="utf-8"', doneCalled.viewMeta.http.headers['content-type'], 'the content-type cannot be overrule');
}

}));
Expand Down

0 comments on commit 21c566a

Please sign in to comment.