Skip to content

Commit

Permalink
fix passing arbitrary props to fragmentArray.createFragment (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwickern authored Mar 14, 2024
1 parent d39e94c commit 49fc7bc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon/array/fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const FragmentArray = StatefulArray.extend({
this.key,
props
);
const fragment = recordData._fragmentGetRecord();
const fragment = recordData._fragmentGetRecord(props);
return this.pushObject(fragment);
},
});
Expand Down
13 changes: 13 additions & 0 deletions tests/unit/fragment_array_property_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,4 +585,17 @@ module('unit - `MF.fragmentArray` property', function (hooks) {
);
});
});

test('pass arbitrary props to createFragment', async function (assert) {
pushPerson(1);

const person = await store.findRecord('person', 1);
const address = person.addresses.createFragment({
street: '1 Dungeon Cell',
extra: 123,
});

assert.equal(address.street, '1 Dungeon Cell', 'street is correct');
assert.equal(address.extra, 123, 'extra property is correct');
});
});
10 changes: 10 additions & 0 deletions tests/unit/fragment_property_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,4 +520,14 @@ module('unit - `MF.fragment` property', function (hooks) {
assert.ok(newName.isDestroying, 'the new fragment is being destroyed');
});
});

test('pass arbitrary props to createFragment', async function (assert) {
const address = store.createFragment('address', {
street: '1 Dungeon Cell',
extra: 123,
});

assert.equal(address.street, '1 Dungeon Cell', 'street is correct');
assert.equal(address.extra, 123, 'extra property is correct');
});
});

0 comments on commit 49fc7bc

Please sign in to comment.