Skip to content

Commit

Permalink
Merge remote-tracking branch 'amb26/FLUID-5036'
Browse files Browse the repository at this point in the history
* amb26/FLUID-5036:
  FLUID-5036: Reworked test cases for this issue so they are valid, as well as resolving faulty diagnostic from the framework
  • Loading branch information
michelled committed Jun 27, 2013
2 parents 8852f45 + 64a7eef commit 6598039
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/webapp/framework/core/js/FluidIoC.js
Expand Up @@ -155,7 +155,8 @@ var fluid_1_5 = fluid_1_5 || {};
});

var record = {options: {}};
fluid.model.applyChangeRequest(record, {path: targetSegs, type: "MERGE", value: source});
var primitiveSource = fluid.isPrimitive(source);
fluid.model.applyChangeRequest(record, {path: targetSegs, type: primitiveSource? "ADD": "MERGE", value: source});
return $.extend(record, {contextThat: contextThat, recordType: sourceType, priority: fluid.mergeRecordTypes.distribution + offset});
};

Expand Down
65 changes: 65 additions & 0 deletions src/webapp/tests/framework-tests/core/js/FluidIoCTests.js
Expand Up @@ -2841,5 +2841,70 @@ fluid.registerNamespace("fluid.tests");
var root2 = fluid.tests.fluid5033Root();
jqUnit.assertEquals("Original graded value", 2, root2.options.gradeValue);
});


/** FLUID-5036, Case 1 - The IoCSS source that is fetched from the static environment is not resolved correctly **/
fluid.defaults("fluid.tests.fluid5036_1Root", {
gradeNames: ["fluid.littleComponent", "autoInit"],
components: {
subComponent: {
type: "fluid.littleComponent",
options: {
targetOption: null
}
}
},
source: "{fluid5036_1UserOption}.options.userOption",
distributeOptions: {
source: "{that}.options.source",
removeSource: true,
target: "{that > subComponent}.options.targetOption"
}
});

jqUnit.test("FLUID-5036, Case 1 - The IoCSS source that is fetched from the static environment is not resolved correctly", function () {
var userOption = 10;

fluid.staticEnvironment.fluid5036_1UserOption = fluid.littleComponent({
gradeNames: "fluid5036_1UserOption",
userOption: userOption
});
var root = fluid.tests.fluid5036_1Root();

jqUnit.assertEquals("The user option fetched from the static environment is passed down the target", userOption, root.subComponent.options.targetOption);
});

/** FLUID-5036, Case 2 - The IoCSS source that is fetched from the static environment is not resolved correctly **/
fluid.defaults("fluid.tests.fluid5036_2Root", {
gradeNames: ["fluid.littleComponent", "autoInit"],
// Note: this is not a recommended implementation technique, causing double nesting of options - this test is purely intendend to verify fix to a
// framework issue which caused a faulty diagnostic "Malformed context reference without }" as well as to verify that at least some sensible effect
// results from this reference. In general, i) only components are resolvable as context references (including in the static environment) and
// ii) components should not be passed through options material as a whole - they should either be injected as subcomponents or else options
// material selected from them resolved into other options
source: "{fluid5036_2UserOption}",
components: {
subComponent: {
type: "fluid.littleComponent"
}
},
distributeOptions: {
source: "{that}.options.source",
removeSource: true,
target: "{that > subComponent}.options"
}
});

jqUnit.test("FLUID-5036, Case 2 - The IoCSS source that is fetched from the static environment is not resolved correctly", function () {
var targetOption = 10;

fluid.staticEnvironment.fluid5036_2UserOption = fluid.littleComponent({
gradeNames: "fluid5036_2UserOption",
targetOption: targetOption
});
var root = fluid.tests.fluid5036_2Root();

jqUnit.assertEquals("The user option fetched from the static environment is passed down the target", targetOption, root.subComponent.options.options.targetOption);
});

})(jQuery);

0 comments on commit 6598039

Please sign in to comment.