My Listing model:
import DS from 'ember-data';
export default DS.Model.extend({
Collections: DS.hasMany('collection', {async: true}),
DisplayCompliance: DS.attr(), //POJO
LastCachedTimestamp: DS.attr('string'),
ResourceUri: DS.attr('string'),
StandardFields: DS.attr(), //POJO
CustomFields: DS.attr(), //POJO
RentalCalendar: DS.attr() //POJO
});
My util test, which uses the model:
import { test, moduleForModel } from 'ember-qunit';
import getStandardField from 'my/utils/get-standard-field';
moduleForModel('listing', 'getStandardField', {
needs: ['model:collection']
});
test('can get standard field', function () {
var listing = this.subject(),
result = getStandardField(listing, 'TestField');
Ember.run(function () {
listing.set('StandardFields', [{'TestField': 'TestValue'}]);
});
equal(result, 'TestValue', 'Gets standard field value');
});
When I do a JSON.stringify on the listing object passed into the getStandardFields util function, I get:
{"LastCachedTimestamp":null,"ResourceUri":null,"Collections":[]}
The POJO attributes are missing. Is there a way to wire them up?