From bc09a7c4d30e11db9b50eaabf7af034f1c5a0c3d Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 8 Jan 2020 15:36:17 +0000 Subject: [PATCH] Fixed invite management tests no issue - adjusts mirage config so that we're correctly serializing foreign keys - our API outputs (and our app code expects) foreign keys for non-embedded resources to be in the format `{relationship_name}_id` but mirage's default REST serializer does not include the `_id` suffix - tests started failing because https://github.com/TryGhost/Ghost-Admin/commit/c46d04f6120302e1e73edb473f04b4108328672d introduced a direct access of the invite->role relationship which Ember Data was not correctly creating when mirage was outputting `role` rather than `role_id` --- ghost/admin/mirage/serializers/application.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ghost/admin/mirage/serializers/application.js b/ghost/admin/mirage/serializers/application.js index 8de724e520..05f2af0352 100644 --- a/ghost/admin/mirage/serializers/application.js +++ b/ghost/admin/mirage/serializers/application.js @@ -19,6 +19,10 @@ export default RestSerializer.extend({ return underscore(relationship); }, + keyForForeignKey(relationshipName) { + return `${underscore(relationshipName)}_id`; + }, + serialize(object, request) { // Ember expects pluralized responses for the post, user, and invite models, // and this shortcut will ensure that those models are pluralized