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

Calling validate() after setting async validated property #200

Closed
nkgm opened this issue Aug 19, 2017 · 1 comment · Fixed by #386
Closed

Calling validate() after setting async validated property #200

nkgm opened this issue Aug 19, 2017 · 1 comment · Fixed by #386

Comments

@nkgm
Copy link

nkgm commented Aug 19, 2017

This is derived from a relevant tests/unit/changeset-test.js test:

test('#validate marks actual valid changes', function(assert) {
  let done = assert.async();
  dummyModel.setProperties({ name: 'Jim Bob', password: true, passwordConfirmation: true });
  let dummyChangeset = new Changeset(dummyModel, dummyValidator, dummyValidations);

  dummyChangeset.set('name', 'foo bar');
  dummyChangeset.set('password', false);
  dummyChangeset.set('async', true);

  run(() => {
    dummyChangeset.validate().then(() => {
      assert.deepEqual(get(dummyChangeset, 'changes'), [
        { key: 'name', value: 'foo bar' }, 
        { key: 'async', value: true } // <- FAILS
      ]);
      done();
    });
  });
});

The above assertion fails because async's validation still hasn't resolved by the time validate() is called. Is this intended behavior?

If the changeset is created with { skipValidate: true } the assertion passes.

@snewcomer
Copy link
Collaborator

@nkgm So is the intended effect here to ensure all validators, async or not have resolved before determining the changesets validation is done? This seems reasonable...

@snewcomer snewcomer mentioned this issue Jul 6, 2018
8 tasks
snewcomer added a commit that referenced this issue Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants