Skip to content

Instantly share code, notes, and snippets.

@RyanHirsch
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save RyanHirsch/9bb5f7832ca5ffd7baa6 to your computer and use it in GitHub Desktop.

Select an option

Save RyanHirsch/9bb5f7832ca5ffd7baa6 to your computer and use it in GitHub Desktop.
EmberData Model Test
import { test, moduleForModel } from 'ember-qunit';
moduleForModel('user-profile', 'UserProfile', {
// Specify the other units that are required for this test.
needs: []
});
test('display name works', function() {
var model = this.subject();
var store = this.store();
var managerFoo = this.subject({
first: "First",
last: "Last"
});
equal(managerFoo.get('displayName'), 'First Last');
});
import DS from 'ember-data';
var attr = DS.attr;
var hasMany = DS.hasMany;
var belongsTo = DS.belongsTo;
export default DS.Model.extend({
prefix: attr('string'),
first: attr('string'),
middle: attr('string'),
last: attr('string'),
suffix: attr('string'),
title: attr('string'),
priPhone: attr('string'),
altPhone: attr('string'),
site: attr('string'),
email: attr('string'),
firstLogon: attr('date'),
displayName: function() {
return '%@ %@'.fmt(this.get('first'), this.get('last'));
}.property('first', 'last')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment