Skip to content

Commit 49fc7bc

Browse files
authored
fix passing arbitrary props to fragmentArray.createFragment (#486)
1 parent d39e94c commit 49fc7bc

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

addon/array/fragment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const FragmentArray = StatefulArray.extend({
149149
this.key,
150150
props
151151
);
152-
const fragment = recordData._fragmentGetRecord();
152+
const fragment = recordData._fragmentGetRecord(props);
153153
return this.pushObject(fragment);
154154
},
155155
});

tests/unit/fragment_array_property_test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,4 +585,17 @@ module('unit - `MF.fragmentArray` property', function (hooks) {
585585
);
586586
});
587587
});
588+
589+
test('pass arbitrary props to createFragment', async function (assert) {
590+
pushPerson(1);
591+
592+
const person = await store.findRecord('person', 1);
593+
const address = person.addresses.createFragment({
594+
street: '1 Dungeon Cell',
595+
extra: 123,
596+
});
597+
598+
assert.equal(address.street, '1 Dungeon Cell', 'street is correct');
599+
assert.equal(address.extra, 123, 'extra property is correct');
600+
});
588601
});

tests/unit/fragment_property_test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,4 +520,14 @@ module('unit - `MF.fragment` property', function (hooks) {
520520
assert.ok(newName.isDestroying, 'the new fragment is being destroyed');
521521
});
522522
});
523+
524+
test('pass arbitrary props to createFragment', async function (assert) {
525+
const address = store.createFragment('address', {
526+
street: '1 Dungeon Cell',
527+
extra: 123,
528+
});
529+
530+
assert.equal(address.street, '1 Dungeon Cell', 'street is correct');
531+
assert.equal(address.extra, 123, 'extra property is correct');
532+
});
523533
});

0 commit comments

Comments
 (0)