Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix passing arbitrary props to fragmentArray.createFragment #486

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});
});
Loading