Fix requests payload

This commit is contained in:
Piotr Sarnacki 2015-11-30 14:07:58 +01:00
parent e8f2e5ae97
commit 2be45cdc18
2 changed files with 35 additions and 11 deletions

View File

@ -1,11 +0,0 @@
`import Ember from 'ember'`
`import ApplicationSerializer from 'travis/serializers/application'`
Serializer = ApplicationSerializer.extend
attrs: {
branch_name: { key: 'branch' }
tag_name: { key: 'tag' }
repo: { key: 'repository_id' }
}
`export default Serializer`

View File

@ -0,0 +1,35 @@
import Ember from 'ember';
import V2FallbackSerializer from 'travis/serializers/v2_fallback';
var Serializer = V2FallbackSerializer.extend({
isNewSerializerAPI: true,
attrs: {
branch_name: { key: 'branch' },
tag_name: { key: 'tag' }
},
keyForV2Relationship: function(key, typeClass, method) {
if (key === 'repo') {
return 'repository_id';
} else {
return this._super.apply(this, arguments);
}
},
normalizeArrayResponse: function(store, primaryModelClass, payload, id, requestType) {
var result;
if (payload.commits) {
payload.requests.forEach(function(request) {
var commit, commit_id;
commit_id = request.commit_id;
if (commit = payload.commits.findBy('id', commit_id)) {
request.commit = commit;
return delete request.commit_id;
}
});
}
return this._super.apply(this, arguments);
}
});
export default Serializer;