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

Do not clear changes after pushErrors #311

Merged
merged 2 commits into from
Aug 28, 2018
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
4 changes: 1 addition & 3 deletions addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,7 @@ export function changeset(
},

/**
* Manually push multiple errors to the changeset as an array. If there is
* an existing error or change for `key`, it will be overwritten.
* Manually push multiple errors to the changeset as an array.
*/
pushErrors(
key /*: string */,
Expand All @@ -537,7 +536,6 @@ export function changeset(
validation = [...v, ...newErrors];

let c = (this /*: ChangesetDef */)
c._deleteKey(CHANGES, key);
c.notifyPropertyChange(ERRORS);
c.notifyPropertyChange(key);

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/changeset-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ module('Unit | Utility | changeset', function(hooks) {
assert.ok(get(dummyChangeset, 'isInvalid'), 'should be invalid');
assert.deepEqual(get(dummyChangeset, 'error.email.validation'), ['Email already taken', 'Invalid email format'], 'should push the error');
assert.equal(get(dummyChangeset, 'error.email.value'), '[email protected]', 'pushErrors uses already present value');
assert.deepEqual(get(dummyChangeset, 'changes'), [], 'pushErrors clears the changes on the changeset');
assert.deepEqual(get(dummyChangeset, 'changes'), [{ key: 'email', value: '[email protected]' }], 'pushErrors does not clear the changes on the changeset');
dummyChangeset.set('email', '[email protected]');
assert.ok(get(dummyChangeset, 'isValid'), 'should be valid');
assert.deepEqual(get(dummyChangeset, 'changes')[0], { key: 'email', value: '[email protected]' }, 'has correct changes');
Expand Down