diff --git a/addon/utils/merge-deep.ts b/addon/utils/merge-deep.ts index f82e0b74..3d697975 100644 --- a/addon/utils/merge-deep.ts +++ b/addon/utils/merge-deep.ts @@ -97,7 +97,7 @@ function mergeTargetAndSource(target: any, source: any, options: Options): any { // else safe key on object if (propertyIsOnObject(target, key) && isMergeableObject(source[key]) && !source[key].hasOwnProperty('value')) { - target[key] = mergeDeep(options.safeGet(target, key), options.safeGet(source, key), options); + options.safeSet(target, key, mergeDeep(options.safeGet(target, key), options.safeGet(source, key), options)); } else { let next = source[key]; if (next && next instanceof Change) { diff --git a/tests/dummy/app/components/changeset-form.ts b/tests/dummy/app/components/changeset-form.ts index c4a1a51a..e9d8f9e3 100644 --- a/tests/dummy/app/components/changeset-form.ts +++ b/tests/dummy/app/components/changeset-form.ts @@ -4,7 +4,10 @@ import Changeset from 'ember-changeset' export default class ChangesetForm extends Component { model = { - email: 'something' + user: { + email: 'something' + }, + cid: '1' } changeset = new Changeset(this.model) diff --git a/tests/dummy/app/templates/components/changeset-form.hbs b/tests/dummy/app/templates/components/changeset-form.hbs index eee2fd44..7160acb7 100644 --- a/tests/dummy/app/templates/components/changeset-form.hbs +++ b/tests/dummy/app/templates/components/changeset-form.hbs @@ -1,15 +1,26 @@ -

Changeset value: {{this.changeset.email}}

+

Changeset Email: {{this.changeset.user.email}}

+

Changeset cid: {{this.changeset.cid}}


-

Model value: {{this.model.email}}

+

Model Email: {{this.model.user.email}}

+

Model cid: {{this.model.cid}}

+ + + + diff --git a/tests/integration/components/changeset-form-test.js b/tests/integration/components/changeset-form-test.js index de44e690..d029db04 100644 --- a/tests/integration/components/changeset-form-test.js +++ b/tests/integration/components/changeset-form-test.js @@ -8,10 +8,12 @@ module('Integration | Component | changeset-form', function(hooks) { test('it renders', async function(assert) { await render(hbs``); - await fillIn('[data-test-email]', 'foo'); + await fillIn('[data-test-user-email]', 'foo'); + await fillIn('[data-test-cid]', 2); await click('[data-test-submit]'); - assert.equal(find('[data-test-model-email]').textContent.trim(), 'foo', 'has email after submit'); - assert.equal(find('[data-test-changeset-email]').textContent.trim(), 'foo', 'changeset has email after submit'); + assert.equal(find('[data-test-model-cid]').textContent.trim(), '2', 'has email after submit'); + assert.equal(find('[data-test-model-user-email]').textContent.trim(), 'foo', 'has email after submit'); + assert.equal(find('[data-test-changeset-user-email]').textContent.trim(), 'foo', 'changeset has email after submit'); }); });