Skip to content

Instantly share code, notes, and snippets.

@Baukereg
Last active May 9, 2017 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Baukereg/bb984da5c033b30498fb7679813755de to your computer and use it in GitHub Desktop.
Save Baukereg/bb984da5c033b30498fb7679813755de to your computer and use it in GitHub Desktop.
CP Validations nested key
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Model from "ember-data/model";
import { validator, buildValidations } from 'ember-cp-validations';
const Validations = buildValidations({
'notification.subject': validator('presence', true)
});
export default Model.extend(Validations, {
notification: null
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default function destroyApp(application) {
Ember.run(application, 'destroy');
}
import Resolver from '../../resolver';
import config from '../../config/environment';
const resolver = Resolver.create();
resolver.namespace = {
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix
};
export default resolver;
import Ember from 'ember';
import Application from '../../app';
import config from '../../config/environment';
const { run } = Ember;
const assign = Ember.assign || Ember.merge;
export default function startApp(attrs) {
let application;
let attributes = assign({rootElement: "#test-root"}, config.APP);
attributes = assign(attributes, attrs); // use defaults, but you can override;
run(() => {
application = Application.create(attributes);
application.setupForTesting();
application.injectTestHelpers();
});
return application;
}
import resolver from './helpers/resolver';
import {
setResolver
} from 'ember-qunit';
setResolver(resolver);
import { moduleForModel, test } from 'ember-qunit';
moduleForModel('report', 'Unit | Model | report', {
needs: ['validator:presence']
});
test('it exists', function(assert) {
let model = this.subject();
// let store = this.store();
assert.ok(!!model);
});
{
"version": "0.12.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": true
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.13.0",
"ember-cp-validations": "3.3.1",
"ember-template-compiler": "2.13.0",
"ember-testing": "2.13.0"
},
"addons": {
"ember-data": "2.13.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment