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

update to 3.1 and fix ObjectProxy extends validations bug #586

Merged
merged 2 commits into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 2 deletions addon/validations/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ export default function buildValidations(validations = {}, globalOptions = {}) {
this._super(...arguments);

// Count number of mixins to bypass super check if there is more than 1
this[VALIDATIONS_MIXIN_COUNT] = this[VALIDATIONS_MIXIN_COUNT] || 0;
validationMixinCount = ++this[VALIDATIONS_MIXIN_COUNT];
validationMixinCount = (this.get(VALIDATIONS_MIXIN_COUNT) || 0) + 1;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get(this, VALIDATIONS_MIXIN_COUNT)

this.set(VALIDATIONS_MIXIN_COUNT, validationMixinCount);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set(this, VALIDATIONS_MIXIN_COUNT, validationMixinCount)

},
[VALIDATIONS_CLASS]: computed(function() {
if (!Validations) {
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
"babel-eslint": "^8.2.3",
"bootstrap-sass": "^3.3.7",
"broccoli-asset-rev": "^2.4.6",
"ember-bootstrap": "^1.2.1",
"ember-cli": "~3.0.2",
"ember-cli-app-version": "^2.0.0",
"ember-bootstrap": "^1.2.2",
"ember-cli": "~3.1",
"ember-cli-app-version": "^3.1.3",
"ember-cli-autoprefixer": "^0.7.0",
"ember-cli-changelog": "0.3.4",
"ember-cli-code-coverage": "0.4.1",
Expand All @@ -53,24 +53,24 @@
"ember-cli-htmlbars-inline-precompile": "^1.0.0",
"ember-cli-inject-live-reload": "^1.4.1",
"ember-cli-moment-shim": "^3.3.3",
"ember-cli-qunit": "^4.1.1",
"ember-cli-qunit": "^4.3.2",
"ember-cli-release": "1.0.0-beta.2",
"ember-cli-sass": "^7.1.7",
"ember-cli-shims": "^1.2.0",
"ember-cli-sri": "^2.1.1",
"ember-cli-uglify": "^2.0.0",
"ember-cli-yuidoc": "^0.8.8",
"ember-code-snippet": "^2.0.1",
"ember-data": "^2.18.0",
"ember-data": "~3.1",
"ember-decorators": "^1.3.4",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-font-awesome": "^3.0.5",
"ember-load-initializers": "^1.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-qunit-nice-errors": "^1.2.0",
"ember-resolver": "^4.3.0",
"ember-source": "~3.0.0",
"ember-resolver": "^4.5.0",
"ember-source": "~3.1",
"ember-source-channel-url": "^1.0.1",
"ember-test-selectors": "^0.3.8",
"ember-truth-helpers": "2.0.0",
Expand All @@ -80,7 +80,7 @@
"eslint-plugin-ember": "^5.0.0",
"eslint-plugin-node": "^5.2.1",
"eslint-plugin-prettier": "^2.6.0",
"loader.js": "^4.2.3",
"loader.js": "^4.6.0",
"prettier": "^1.10.2",
"qunit-dom": "^0.5.0",
"yuidoc-ember-theme": "^2.0.1"
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/models/company.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
buildValidations
} from 'ember-cp-validations';

const Validations = buildValidations({
export const Validations = buildValidations({
name: validator('presence', { presence: true, description: 'Name' })
});

Expand Down
28 changes: 28 additions & 0 deletions tests/unit/validations/ember-proxy-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import ObjectProxy from '@ember/object/proxy';
import { run } from '@ember/runloop';
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { Validations } from 'dummy/models/company';

module('Unit | Validations | Ember ObjectProxy', function(hooks) {
setupTest(hooks);

test('extend ObjectProxy with validations', function(assert) {
run(() => {
let company = this.owner.lookup('service:store').createRecord('company');

const container = this.owner.ownerInjection();
const proxy = ObjectProxy.extend(Validations).create(container, {
content: company
});

assert.notOk(proxy.get('validations.isValid'));
assert.notOk(company.get('validations.isValid'));

proxy.set('name', 'whatever');

assert.ok(proxy.get('validations.isValid'));
assert.ok(company.get('validations.isValid'));
});
});
});
Loading