From ea5efcaefb94fe31254e6df3c84503e9700e8e33 Mon Sep 17 00:00:00 2001 From: Pat O'Callaghan Date: Tue, 28 Sep 2021 12:26:49 +0100 Subject: [PATCH 1/3] Upgrade to Ember Data 3.24 --- package.json | 4 +- tests/helpers/utility-methods.js | 9 +- tests/unit/shared-adapter-behaviour.js | 7 +- yarn.lock | 339 +++++++++++++++---------- 4 files changed, 215 insertions(+), 144 deletions(-) diff --git a/package.json b/package.json index db7b33e7..a194d16a 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "ember-cli-inject-live-reload": "^2.1.0", "ember-cli-sri": "^2.1.1", "ember-cli-terser": "^4.0.2", - "ember-data": "~3.9", + "ember-data": "~3.24", "ember-data-model-fragments": "^4.0.0", "ember-disable-prototype-extensions": "^1.1.3", "ember-django-adapter": "^2.1.1", @@ -81,7 +81,7 @@ "qunit-dom": "^1.6.0" }, "resolutions": { - "ember-data": "3.9.0" + "ember-data": "3.24.2" }, "keywords": [ "ember-addon", diff --git a/tests/helpers/utility-methods.js b/tests/helpers/utility-methods.js index 8bc0cd92..0de627ef 100644 --- a/tests/helpers/utility-methods.js +++ b/tests/helpers/utility-methods.js @@ -3,6 +3,7 @@ import { typeOf } from '@ember/utils'; import FactoryGuy, { manualSetup } from 'ember-data-factory-guy'; import DRFAdapter from 'ember-django-adapter/adapters/drf'; import DRFSerializer from 'ember-django-adapter/serializers/drf'; +import RESTAdapter from '@ember-data/adapter/rest'; import ActiveModelAdapter, { ActiveModelSerializer, } from 'active-model-adapter'; @@ -129,7 +130,13 @@ export function containerSetup(application, serializerType) { let store = application.lookup('service:store'); let adapterType = serializerType === '-json' ? '-rest' : serializerType; - let adapter = application.lookup('adapter:' + adapterType); + let adapter; + if (serializerType === '-json' || serializerType === '-rest') { + application.register(`adapter:-rest`, RESTAdapter, { + singleton: false, + }); + } + adapter = application.lookup('adapter:' + adapterType); adapter = adapter.reopen(AdapterFetch); serializerType = serializerType === '-json' ? '-default' : serializerType; diff --git a/tests/unit/shared-adapter-behaviour.js b/tests/unit/shared-adapter-behaviour.js index a323acee..a4db8beb 100644 --- a/tests/unit/shared-adapter-behaviour.js +++ b/tests/unit/shared-adapter-behaviour.js @@ -74,12 +74,15 @@ SharedBehavior.mockFindRecordCommonTests = function () { }); test('returns id fails with 404 if record for id and model type not found in store', async function (assert) { + assert.expect(1); let profileId = 1; mockFindRecord('profile').returns({ id: profileId }); - await FactoryGuy.store.findRecord('profile', profileId).catch((reason) => { + try { + await FactoryGuy.store.findRecord('profile', profileId); + } catch (reason) { assert.equal(reason.errors[0].status, '404'); - }); + } }); // test("returns model succeeds", async function(assert) { diff --git a/yarn.lock b/yarn.lock index 86732e12..18435ff0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -959,7 +959,7 @@ debug "^4.1.0" globals "^11.1.0" -"@babel/types@^7.1.5", "@babel/types@^7.1.6", "@babel/types@^7.12.1", "@babel/types@^7.15.4", "@babel/types@^7.15.6", "@babel/types@^7.4.4", "@babel/types@^7.7.0", "@babel/types@^7.7.2": +"@babel/types@^7.1.6", "@babel/types@^7.12.1", "@babel/types@^7.15.4", "@babel/types@^7.15.6", "@babel/types@^7.4.4", "@babel/types@^7.7.0", "@babel/types@^7.7.2": version "7.15.6" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.15.6.tgz#99abdc48218b2881c058dd0a7ab05b99c9be758f" integrity sha512-BPU+7QhqNjmWyDO0/vitH/CuhpV8ZmK1wpKva8nuyNF5MJfuRNWMc+hc14+u9xT93kvykMdncrJT19h74uB1Ig== @@ -975,11 +975,131 @@ exec-sh "^0.3.2" minimist "^1.2.0" +"@ember-data/adapter@3.24.2": + version "3.24.2" + resolved "https://registry.yarnpkg.com/@ember-data/adapter/-/adapter-3.24.2.tgz#dd0b0f4f3c6e83dcba8c1a65d799a4c737f5eeec" + integrity sha512-3NmgrGNOUYKseJjUHcre3IOhLlpPMg7o9o8ZNRyi7r2M1n9flsXuKzJPMiteAic3U7bhODk44gorYjQ6goCzHw== + dependencies: + "@ember-data/private-build-infra" "3.24.2" + "@ember-data/store" "3.24.2" + "@ember/edition-utils" "^1.2.0" + "@ember/string" "^1.0.0" + ember-cli-babel "^7.18.0" + ember-cli-test-info "^1.0.0" + ember-cli-typescript "^3.1.3" + +"@ember-data/canary-features@3.24.2": + version "3.24.2" + resolved "https://registry.yarnpkg.com/@ember-data/canary-features/-/canary-features-3.24.2.tgz#bd91beda313fc4d7ef3d8fc5dc709d53350c246c" + integrity sha512-duCgl99T6QQ4HuXNMI1l1vA8g7cvi7Ol/loVFOtkJn+MOlcQOzXNATuNqC/LPjTiHpPdQTL18+fq2wIZEDnq0w== + dependencies: + ember-cli-babel "^7.18.0" + ember-cli-typescript "^3.1.3" + +"@ember-data/debug@3.24.2": + version "3.24.2" + resolved "https://registry.yarnpkg.com/@ember-data/debug/-/debug-3.24.2.tgz#6b96fb9cd0914071efb9ac3c6befc1a3a55f5d38" + integrity sha512-RPTGoSFPGjhB7ZVbv3eGFL6NeZKCtWv9BrZwrZH7ZvHWN1Vc7vYG3NAsLAafpjbkfSo4KG2OKHZGftpXCIl2Og== + dependencies: + "@ember-data/private-build-infra" "3.24.2" + "@ember/edition-utils" "^1.2.0" + "@ember/string" "^1.0.0" + ember-cli-babel "^7.18.0" + ember-cli-test-info "^1.0.0" + ember-cli-typescript "^3.1.3" + +"@ember-data/model@3.24.2": + version "3.24.2" + resolved "https://registry.yarnpkg.com/@ember-data/model/-/model-3.24.2.tgz#8d718b8151eb2489328c5957d9ffc367b5b9a512" + integrity sha512-vKBYlWZYk0uh+7TiEYADQakUpJLbZ+ahU9ez2WEMtsdl4cDHpEBwyFH76Zmh3dp2Pz/aq5UwOtEHz/ggpUo7fQ== + dependencies: + "@ember-data/canary-features" "3.24.2" + "@ember-data/private-build-infra" "3.24.2" + "@ember-data/store" "3.24.2" + "@ember/edition-utils" "^1.2.0" + "@ember/string" "^1.0.0" + ember-cli-babel "^7.18.0" + ember-cli-string-utils "^1.1.0" + ember-cli-test-info "^1.0.0" + ember-cli-typescript "^3.1.3" + ember-compatibility-helpers "^1.2.0" + inflection "1.12.0" + +"@ember-data/private-build-infra@3.24.2": + version "3.24.2" + resolved "https://registry.yarnpkg.com/@ember-data/private-build-infra/-/private-build-infra-3.24.2.tgz#2b77fb4490a6c657d9f82ce8c54fe22157e03963" + integrity sha512-uYv9BOGaNxsSacE0jFRFhrs/Xg6f8Rma2Ap/mVjwouBvu+DV2cl5E2zIMalygu/ngIiGhiNUeUp2RpjSpR054w== + dependencies: + "@babel/plugin-transform-block-scoping" "^7.8.3" + "@ember-data/canary-features" "3.24.2" + "@ember/edition-utils" "^1.2.0" + babel-plugin-debug-macros "^0.3.3" + babel-plugin-filter-imports "^4.0.0" + babel6-plugin-strip-class-callcheck "^6.0.0" + broccoli-debug "^0.6.5" + broccoli-file-creator "^2.1.1" + broccoli-funnel "^2.0.2" + broccoli-merge-trees "^4.2.0" + broccoli-rollup "^4.1.1" + calculate-cache-key-for-tree "^2.0.0" + chalk "^4.0.0" + ember-cli-babel "^7.18.0" + ember-cli-path-utils "^1.0.0" + ember-cli-string-utils "^1.1.0" + ember-cli-typescript "^3.1.3" + ember-cli-version-checker "^5.1.1" + esm "^3.2.25" + git-repo-info "^2.1.1" + glob "^7.1.6" + npm-git-info "^1.0.3" + rimraf "^3.0.2" + rsvp "^4.8.5" + semver "^7.1.3" + silent-error "^1.1.1" + +"@ember-data/record-data@3.24.2": + version "3.24.2" + resolved "https://registry.yarnpkg.com/@ember-data/record-data/-/record-data-3.24.2.tgz#cf07dd13c74d02046af2dc4a9102f9f6cb897184" + integrity sha512-vdsWiPp29lwgMeyf4O1sXZ8xJf/zPCIEfksYeGaJ9VhiTKOucqiRxIFeI2cdyqxkM0frtCyNwYEntpy871Os2Q== + dependencies: + "@ember-data/canary-features" "3.24.2" + "@ember-data/private-build-infra" "3.24.2" + "@ember-data/store" "3.24.2" + "@ember/edition-utils" "^1.2.0" + "@ember/ordered-set" "^4.0.0" + ember-cli-babel "^7.18.0" + ember-cli-test-info "^1.0.0" + ember-cli-typescript "^3.1.3" + "@ember-data/rfc395-data@^0.0.4": version "0.0.4" resolved "https://registry.yarnpkg.com/@ember-data/rfc395-data/-/rfc395-data-0.0.4.tgz#ecb86efdf5d7733a76ff14ea651a1b0ed1f8a843" integrity sha512-tGRdvgC9/QMQSuSuJV45xoyhI0Pzjm7A9o/MVVA3HakXIImJbbzx/k/6dO9CUEQXIyS2y0fW6C1XaYOG7rY0FQ== +"@ember-data/serializer@3.24.2": + version "3.24.2" + resolved "https://registry.yarnpkg.com/@ember-data/serializer/-/serializer-3.24.2.tgz#d95816f4af4b9d3031bdd198cd10e6bde3fa8b17" + integrity sha512-so/NkQgtecXqPdFMjUHkXQ73n9TFVMigZeCFuippkP3lQu2HquJ9u/e+WRcgLzziU7q+eBTnt2Lar9uLkXMNyw== + dependencies: + "@ember-data/private-build-infra" "3.24.2" + "@ember-data/store" "3.24.2" + ember-cli-babel "^7.18.0" + ember-cli-test-info "^1.0.0" + ember-cli-typescript "^3.1.3" + +"@ember-data/store@3.24.2": + version "3.24.2" + resolved "https://registry.yarnpkg.com/@ember-data/store/-/store-3.24.2.tgz#2583e03f8c51c5b049a29bbed304ae78085e8b9b" + integrity sha512-FJVZIrCwFDebh/s3Gy4YC+PK7BRaDIudor53coia236hpAW9eO/itO/ZbOGt9eFumWzX6eUFxJixD0o9FvGybA== + dependencies: + "@ember-data/canary-features" "3.24.2" + "@ember-data/private-build-infra" "3.24.2" + "@ember/string" "^1.0.0" + ember-cli-babel "^7.18.0" + ember-cli-path-utils "^1.0.0" + ember-cli-typescript "^3.1.3" + heimdalljs "^0.3.0" + "@ember-template-lint/todo-utils@^10.0.0": version "10.0.0" resolved "https://registry.yarnpkg.com/@ember-template-lint/todo-utils/-/todo-utils-10.0.0.tgz#085aafcf31ca04ba4d3a9460f088aed752b90ea8" @@ -1007,14 +1127,21 @@ mkdirp "^1.0.4" silent-error "^1.1.1" -"@ember/ordered-set@^2.0.3": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@ember/ordered-set/-/ordered-set-2.0.3.tgz#2ac1ca73b3bd116063cae814898832ef434a57f9" - integrity sha512-F4yfVk6WMc4AUHxeZsC3CaKyTvO0qSZJy7WWHCFTlVDQw6vubn+FvnGdhzpN1F00EiXMI4Tv1tJdSquHcCnYrA== +"@ember/ordered-set@^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/@ember/ordered-set/-/ordered-set-4.0.0.tgz#c5ec021ab8d4734c6db92708a81edd499d45fd31" + integrity sha512-cUCcme4R5H37HyK8w0qzdG5+lpb3XVr2RQHLyWEP4JsKI66Ob4tizoJOs8rb/XdHCv+F5WeA321hfPMi3DrZbg== dependencies: - ember-cli-babel "^6.16.0" + ember-cli-babel "^7.22.1" ember-compatibility-helpers "^1.1.1" +"@ember/string@^1.0.0": + version "1.0.0" + resolved "https://registry.yarnpkg.com/@ember/string/-/string-1.0.0.tgz#3a2254caedacb95e09071204d36cad49e0f8b855" + integrity sha512-KZ+CcIXFdyIBMztxDMgza4SdLJgIeUgTjDAoHk6M50C2u1X/BK7KWUIN7MIK2LNTOMvbib9lWwEzKboxdI4lBw== + dependencies: + ember-cli-babel "^7.4.0" + "@ember/test-helpers@^2.4.2": version "2.4.2" resolved "https://registry.yarnpkg.com/@ember/test-helpers/-/test-helpers-2.4.2.tgz#e5be97e316dc502d7da933461135fbcb9254726e" @@ -1397,6 +1524,11 @@ "@types/connect" "*" "@types/node" "*" +"@types/broccoli-plugin@^1.3.0": + version "1.3.0" + resolved "https://registry.yarnpkg.com/@types/broccoli-plugin/-/broccoli-plugin-1.3.0.tgz#38f8462fecaebc4e09a32e4d4ed1b9808f75bbca" + integrity sha512-SLk4/hFc2kGvgwNFrpn2O1juxFOllcHAywvlo7VwxfExLzoz1GGJ0oIZCwj5fwSpvHw4AWpZjJ1fUvb62PDayQ== + "@types/chai-as-promised@^7.1.2": version "7.1.4" resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-7.1.4.tgz#caf64e76fb056b8c8ced4b761ed499272b737601" @@ -1711,7 +1843,7 @@ abbrev@1: resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== -abortcontroller-polyfill@^1.3.0, abortcontroller-polyfill@^1.4.0: +abortcontroller-polyfill@^1.4.0: version "1.7.3" resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz#1b5b487bd6436b5b764fd52a612509702c3144b5" integrity sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q== @@ -1759,7 +1891,7 @@ acorn@^6.4.1: resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.2.tgz#35866fd710528e92de10cf06016498e47e39e1e6" integrity sha512-XtGIhXwF8YM8bJhGxG5kXgjkEuNGLTkoYqVE+KMR+aspr4KGYmKYg7yUe3KghyQ9yheNwLnjmzh/7+gfDBmHCQ== -acorn@^7.1.1, acorn@^7.4.0: +acorn@^7.1.0, acorn@^7.1.1, acorn@^7.4.0: version "7.4.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa" integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A== @@ -2338,19 +2470,6 @@ babel-plugin-ember-modules-api-polyfill@^3.5.0: dependencies: ember-rfc176-data "^0.3.17" -babel-plugin-feature-flags@^0.3.1: - version "0.3.1" - resolved "https://registry.yarnpkg.com/babel-plugin-feature-flags/-/babel-plugin-feature-flags-0.3.1.tgz#9c827cf9a4eb9a19f725ccb239e85cab02036fc1" - integrity sha1-nIJ8+aTrmhn3JcyyOehcqwIDb8E= - -babel-plugin-filter-imports@^2.0.4: - version "2.0.4" - resolved "https://registry.yarnpkg.com/babel-plugin-filter-imports/-/babel-plugin-filter-imports-2.0.4.tgz#9209b708ed3b228349c4e6f660358bf02685e803" - integrity sha512-Ra4VylqMFsmTJCUeLRJ/OP2ZqO0cCJQK2HKihNTnoKP4f8IhxHKL4EkbmfkwGjXCeDyXd0xQ6UTK8Nd+h9V/SQ== - dependencies: - "@babel/types" "^7.1.5" - lodash "^4.17.11" - babel-plugin-filter-imports@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/babel-plugin-filter-imports/-/babel-plugin-filter-imports-4.0.0.tgz#068f8da15236a96a9602c36dc6f4a6eeca70a4f4" @@ -2766,11 +2885,6 @@ babel6-plugin-strip-class-callcheck@^6.0.0: resolved "https://registry.yarnpkg.com/babel6-plugin-strip-class-callcheck/-/babel6-plugin-strip-class-callcheck-6.0.0.tgz#de841c1abebbd39f78de0affb2c9a52ee228fddf" integrity sha1-3oQcGr6705943gr/ssmlLuIo/d8= -babel6-plugin-strip-heimdall@^6.0.1: - version "6.0.1" - resolved "https://registry.yarnpkg.com/babel6-plugin-strip-heimdall/-/babel6-plugin-strip-heimdall-6.0.1.tgz#35f80eddec1f7fffdc009811dfbd46d9965072b6" - integrity sha1-NfgO3ewff//cAJgR371G2ZZQcrY= - babylon@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" @@ -3074,7 +3188,7 @@ broccoli-clean-css@^1.1.0: inline-source-map-comment "^1.0.5" json-stable-stringify "^1.0.0" -broccoli-concat@^3.2.2, broccoli-concat@^3.7.5: +broccoli-concat@^3.7.5: version "3.7.5" resolved "https://registry.yarnpkg.com/broccoli-concat/-/broccoli-concat-3.7.5.tgz#223beda8c1184252cf08ae020a3d45ffa6a48218" integrity sha512-rDs1Mej3Ej0Cy5yIO9oIQq5+BCv0opAwS2NW7M0BeCsAMeFM42Z/zacDUC6jKc5OV5wiHvGTyCPLnZkMe0h6kQ== @@ -3325,7 +3439,7 @@ broccoli-persistent-filter@^1.1.6, broccoli-persistent-filter@^1.4.3: symlink-or-copy "^1.0.1" walk-sync "^0.3.1" -broccoli-persistent-filter@^2.1.1, broccoli-persistent-filter@^2.2.1, broccoli-persistent-filter@^2.3.0: +broccoli-persistent-filter@^2.2.1, broccoli-persistent-filter@^2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/broccoli-persistent-filter/-/broccoli-persistent-filter-2.3.1.tgz#4a052e0e0868b344c3a2977e35a3d497aa9eca72" integrity sha512-hVsmIgCDrl2NFM+3Gs4Cr2TA6UPaIZip99hN8mtkaUPgM8UeVnCbxelCvBjUBHo0oaaqP5jzqqnRVvb568Yu5g== @@ -3382,7 +3496,7 @@ broccoli-plugin@^1.0.0, broccoli-plugin@^1.1.0, broccoli-plugin@^1.2.0, broccoli rimraf "^2.3.4" symlink-or-copy "^1.1.8" -broccoli-plugin@^2.1.0: +broccoli-plugin@^2.0.0, broccoli-plugin@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/broccoli-plugin/-/broccoli-plugin-2.1.0.tgz#2fab6c578219cfcc64f773e9616073313fc8b334" integrity sha512-ElE4caljW4slapyEhSD9jU9Uayc8SoSABWdmY9SqbV8DHNxU6xg1jJsPcMm+cXOvggR3+G+OXAYQeFjWVnznaw== @@ -3422,6 +3536,21 @@ broccoli-rollup@^2.1.1: symlink-or-copy "^1.1.8" walk-sync "^0.3.1" +broccoli-rollup@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/broccoli-rollup/-/broccoli-rollup-4.1.1.tgz#7531a24d88ddab9f1bace1c6ee6e6ca74a38d36f" + integrity sha512-hkp0dB5chiemi32t6hLe5bJvxuTOm1TU+SryFlZIs95KT9+94uj0C8w6k6CsZ2HuIdIZg6D252t4gwOlcTXrpA== + dependencies: + "@types/broccoli-plugin" "^1.3.0" + broccoli-plugin "^2.0.0" + fs-tree-diff "^2.0.1" + heimdalljs "^0.2.6" + node-modules-path "^1.0.1" + rollup "^1.12.0" + rollup-pluginutils "^2.8.1" + symlink-or-copy "^1.2.0" + walk-sync "^1.1.3" + broccoli-slow-trees@^3.0.1, broccoli-slow-trees@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/broccoli-slow-trees/-/broccoli-slow-trees-3.1.0.tgz#8e48903f59e061bf1213963733b9e61dec2ee5d7" @@ -3457,26 +3586,6 @@ broccoli-sri-hash@^2.1.0: sri-toolbox "^0.2.0" symlink-or-copy "^1.0.1" -broccoli-stew@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/broccoli-stew/-/broccoli-stew-2.1.0.tgz#ba73add17fda3b9b01d8cfb343a8b613b7136a0a" - integrity sha512-tgCkuTWYl4uf7k7ib2D79KFEj2hCgnTUNPMnrCoAha0/4bywcNccmaZVWtL9Ex37yX5h5eAbnM/ak2ULoMwSSw== - dependencies: - broccoli-debug "^0.6.5" - broccoli-funnel "^2.0.0" - broccoli-merge-trees "^3.0.1" - broccoli-persistent-filter "^2.1.1" - broccoli-plugin "^1.3.1" - chalk "^2.4.1" - debug "^3.1.0" - ensure-posix-path "^1.0.1" - fs-extra "^6.0.1" - minimatch "^3.0.4" - resolve "^1.8.1" - rsvp "^4.8.4" - symlink-or-copy "^1.2.0" - walk-sync "^0.3.3" - broccoli-stew@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/broccoli-stew/-/broccoli-stew-3.0.0.tgz#fd1d19d162ad9490b42e5c563b78c26eb1e80b95" @@ -3752,7 +3861,7 @@ cacheable-request@^2.1.1: normalize-url "2.0.1" responselike "1.0.2" -calculate-cache-key-for-tree@^1.1.0, calculate-cache-key-for-tree@^1.2.0: +calculate-cache-key-for-tree@^1.1.0: version "1.2.3" resolved "https://registry.yarnpkg.com/calculate-cache-key-for-tree/-/calculate-cache-key-for-tree-1.2.3.tgz#5a5e4fcfa2d374a63e47fe967593f179e8282825" integrity sha512-PPQorvdNw8K8k7UftCeradwOmKDSDJs8wcqYTtJPEt3fHbZyK8QsorybJA+lOmk0dgE61vX6R+5Kd3W9h4EMGg== @@ -4764,7 +4873,7 @@ ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.16.0, ember-cli-version-checker "^2.1.2" semver "^5.5.0" -ember-cli-babel@^7.0.0, ember-cli-babel@^7.13.0, ember-cli-babel@^7.13.2, ember-cli-babel@^7.17.2, ember-cli-babel@^7.22.1, ember-cli-babel@^7.23.0, ember-cli-babel@^7.23.1, ember-cli-babel@^7.26.4, ember-cli-babel@^7.26.5, ember-cli-babel@^7.26.6, ember-cli-babel@^7.7.3: +ember-cli-babel@^7.0.0, ember-cli-babel@^7.13.0, ember-cli-babel@^7.13.2, ember-cli-babel@^7.17.2, ember-cli-babel@^7.18.0, ember-cli-babel@^7.22.1, ember-cli-babel@^7.23.0, ember-cli-babel@^7.23.1, ember-cli-babel@^7.26.4, ember-cli-babel@^7.26.5, ember-cli-babel@^7.26.6, ember-cli-babel@^7.4.0, ember-cli-babel@^7.7.3: version "7.26.6" resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-7.26.6.tgz#322fbbd3baad9dd99e3276ff05bc6faef5e54b39" integrity sha512-040svtfj2RC35j/WMwdWJFusZaXmNoytLAMyBDGLMSlRvznudTxZjGlPV6UupmtTBApy58cEF8Fq4a+COWoEmQ== @@ -4935,7 +5044,7 @@ ember-cli-typescript@3.0.0: stagehand "^1.0.0" walk-sync "^2.0.0" -ember-cli-typescript@^2.0.0, ember-cli-typescript@^2.0.2: +ember-cli-typescript@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/ember-cli-typescript/-/ember-cli-typescript-2.0.2.tgz#464984131fbdc05655eb61d1c3cdd911d3137f0d" integrity sha512-7I5azCTxOgRDN8aSSnJZIKSqr+MGnT+jLTUbBYqF8wu6ojs2DUnTePxUcQMcvNh3Q3B1ySv7Q/uZFSjdU9gSjA== @@ -5104,7 +5213,7 @@ ember-cli@~3.28.0: workerpool "^6.1.4" yam "^1.0.0" -ember-compatibility-helpers@^1.1.1, ember-compatibility-helpers@^1.1.2, ember-compatibility-helpers@^1.2.1: +ember-compatibility-helpers@^1.1.1, ember-compatibility-helpers@^1.1.2, ember-compatibility-helpers@^1.2.0, ember-compatibility-helpers@^1.2.1: version "1.2.5" resolved "https://registry.yarnpkg.com/ember-compatibility-helpers/-/ember-compatibility-helpers-1.2.5.tgz#b8363b1d5b8725afa9a4fe2b2986ac28626c6f23" integrity sha512-7cddkQQp8Rs2Mqrj0xqZ0uO7eC9tBCKyZNcP2iE1RxQqOGPv8fiPkj1TUeidUB/Qe80lstoVXWMEuqqhW7Yy9A== @@ -5134,70 +5243,26 @@ ember-data-model-fragments@^4.0.0: git-repo-info "^2.0.0" npm-git-info "^1.0.3" -ember-data@3.9.0: - version "3.9.0" - resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-3.9.0.tgz#9f0d55829e107c57307777bd5cf1e36b088d5c40" - integrity sha512-yU9ptLTX9nmHt8cSuQc5K2tdZFmj0oZIYUt2/TIk0yN9e21oJBI8eOYH2N7KJSxptLWqysCmDh0Vcqs2eZnWUw== - dependencies: - "@ember/ordered-set" "^2.0.3" - "@glimmer/env" "^0.1.7" - babel-plugin-feature-flags "^0.3.1" - babel-plugin-filter-imports "^2.0.4" - babel6-plugin-strip-class-callcheck "^6.0.0" - babel6-plugin-strip-heimdall "^6.0.1" - broccoli-debug "^0.6.5" - broccoli-file-creator "^2.1.1" - broccoli-funnel "^2.0.1" - broccoli-merge-trees "^3.0.2" - broccoli-rollup "^2.1.1" - calculate-cache-key-for-tree "^1.2.0" - chalk "^2.4.1" - ember-cli-babel "^7.7.3" - ember-cli-path-utils "^1.0.0" - ember-cli-string-utils "^1.1.0" - ember-cli-test-info "^1.0.0" - ember-cli-typescript "^2.0.0" - ember-cli-version-checker "^3.1.3" - ember-fetch "^6.5.0" - ember-inflector "^3.0.0" - git-repo-info "^2.0.0" - heimdalljs "^0.3.0" - inflection "^1.12.0" - npm-git-info "^1.0.3" - resolve "^1.8.1" - silent-error "^1.1.1" - -ember-data@~3.9: - version "3.9.3" - resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-3.9.3.tgz#6338ef6a13d30c5d9da56f2bc02bf7f832636b9f" - integrity sha512-t1qfuZeLeUYkhtR4V5FmhKoIkxXwT38CuRTEgyNXHeoMlDeRyj5TR06uPDIVEHJ4T3oOihx0dGZBQM4GKVrY5w== - dependencies: - "@ember/ordered-set" "^2.0.3" +ember-data@3.24.2, ember-data@~3.24: + version "3.24.2" + resolved "https://registry.yarnpkg.com/ember-data/-/ember-data-3.24.2.tgz#34d72b0bc83fce1791bf09a8391425717b9c3f55" + integrity sha512-dfpLagJn09eEcoVqU4NfMs3J+750jJU7rLZA7uFY2/+0M0a4iGhjbm1dVVZQTkrfNiYHXvOOItr1bOT9sMC8Hg== + dependencies: + "@ember-data/adapter" "3.24.2" + "@ember-data/debug" "3.24.2" + "@ember-data/model" "3.24.2" + "@ember-data/private-build-infra" "3.24.2" + "@ember-data/record-data" "3.24.2" + "@ember-data/serializer" "3.24.2" + "@ember-data/store" "3.24.2" + "@ember/edition-utils" "^1.2.0" + "@ember/ordered-set" "^4.0.0" + "@ember/string" "^1.0.0" "@glimmer/env" "^0.1.7" - babel-plugin-feature-flags "^0.3.1" - babel-plugin-filter-imports "^2.0.4" - babel6-plugin-strip-class-callcheck "^6.0.0" - babel6-plugin-strip-heimdall "^6.0.1" - broccoli-debug "^0.6.5" - broccoli-file-creator "^2.1.1" - broccoli-funnel "^2.0.1" - broccoli-merge-trees "^3.0.2" - broccoli-rollup "^2.1.1" - calculate-cache-key-for-tree "^1.2.0" - chalk "^2.4.1" - ember-cli-babel "^7.7.3" - ember-cli-path-utils "^1.0.0" - ember-cli-string-utils "^1.1.0" - ember-cli-test-info "^1.0.0" - ember-cli-typescript "^2.0.0" - ember-cli-version-checker "^3.1.3" - ember-inflector "^3.0.0" - git-repo-info "^2.0.0" - heimdalljs "^0.3.0" - inflection "^1.12.0" - npm-git-info "^1.0.3" - resolve "^1.8.1" - silent-error "^1.1.1" + broccoli-merge-trees "^4.2.0" + ember-cli-babel "^7.18.0" + ember-cli-typescript "^3.1.3" + ember-inflector "^3.0.1" ember-debug-handlers-polyfill@^1.1.1: version "1.1.1" @@ -5226,24 +5291,6 @@ ember-django-adapter@^2.1.1: ember-cli-babel "^6.16.0" ember-inflector "^2.1.0" -ember-fetch@^6.5.0: - version "6.7.2" - resolved "https://registry.yarnpkg.com/ember-fetch/-/ember-fetch-6.7.2.tgz#82efce4a55a64863104347b71e598208b9acf518" - integrity sha512-+Dd++MJVkCXoqX2DPtFDjuoDMcLk+7fphLq7D8OoXwJq9KQMTff07sH18qhxWXV5Hqknvz3Uwy214g54vOboag== - dependencies: - abortcontroller-polyfill "^1.3.0" - broccoli-concat "^3.2.2" - broccoli-debug "^0.6.5" - broccoli-merge-trees "^3.0.0" - broccoli-rollup "^2.1.1" - broccoli-stew "^2.1.0" - broccoli-templater "^2.0.1" - calculate-cache-key-for-tree "^2.0.0" - caniuse-api "^3.0.0" - ember-cli-babel "^6.8.2" - node-fetch "^2.6.0" - whatwg-fetch "^3.0.0" - ember-fetch@^7.0.0: version "7.1.0" resolved "https://registry.yarnpkg.com/ember-fetch/-/ember-fetch-7.1.0.tgz#17549e0df0f8c402b68612aa87f77957fa956ebf" @@ -5270,7 +5317,7 @@ ember-inflector@^2.0.0, ember-inflector@^2.1.0: dependencies: ember-cli-babel "^6.0.0" -ember-inflector@^3.0.0: +ember-inflector@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/ember-inflector/-/ember-inflector-3.0.1.tgz#04be6df4d7e4000f6d6bd70787cdc995f77be4ab" integrity sha512-fngrwMsnhkBt51KZgwNwQYxgURwV4lxtoHdjxf7RueGZ5zM7frJLevhHw7pbQNGqXZ3N+MRkhfNOLkdDK9kFdA== @@ -5796,7 +5843,7 @@ eslint@^7.32.0: text-table "^0.2.0" v8-compile-cache "^2.0.3" -esm@^3.2.4: +esm@^3.2.25, esm@^3.2.4: version "3.2.25" resolved "https://registry.yarnpkg.com/esm/-/esm-3.2.25.tgz#342c18c29d56157688ba5ce31f8431fbb795cc10" integrity sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA== @@ -7228,6 +7275,11 @@ infer-owner@^1.0.3: resolved "https://registry.yarnpkg.com/infer-owner/-/infer-owner-1.0.4.tgz#c4cefcaa8e51051c2a40ba2ce8a3d27295af9467" integrity sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A== +inflection@1.12.0: + version "1.12.0" + resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.12.0.tgz#a200935656d6f5f6bc4dc7502e1aecb703228416" + integrity sha1-ogCTVlbW9fa8TcdQLhrstwMihBY= + inflection@^1.12.0: version "1.13.1" resolved "https://registry.yarnpkg.com/inflection/-/inflection-1.13.1.tgz#c5cadd80888a90cf84c2e96e340d7edc85d5f0cb" @@ -8220,7 +8272,7 @@ lodash.uniqby@^4.7.0: resolved "https://registry.yarnpkg.com/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz#d99c07a669e9e6d24e1362dfe266c67616af1302" integrity sha1-2ZwHpmnp5tJOE2Lf4mbGdhavEwI= -lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.6.1, lodash@^4.7.0: +lodash@^4.17.10, lodash@^4.17.12, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.6.1, lodash@^4.7.0: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -10087,7 +10139,7 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" -rollup-pluginutils@^2.0.1: +rollup-pluginutils@^2.0.1, rollup-pluginutils@^2.8.1: version "2.8.2" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== @@ -10111,6 +10163,15 @@ rollup@^0.57.1: signal-exit "^3.0.2" sourcemap-codec "^1.4.1" +rollup@^1.12.0: + version "1.32.1" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.32.1.tgz#4480e52d9d9e2ae4b46ba0d9ddeaf3163940f9c4" + integrity sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A== + dependencies: + "@types/estree" "*" + "@types/node" "*" + acorn "^7.1.0" + route-recognizer@^0.3.3: version "0.3.4" resolved "https://registry.yarnpkg.com/route-recognizer/-/route-recognizer-0.3.4.tgz#39ab1ffbce1c59e6d2bdca416f0932611e4f3ca3" @@ -10239,7 +10300,7 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.1.1, semver@^6.1.2, semver@^6.3.0: resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== -semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: +semver@^7.1.3, semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5: version "7.3.5" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== From 83421b0e60be4c054f5099141a921da2c817c542 Mon Sep 17 00:00:00 2001 From: Pat O'Callaghan Date: Wed, 29 Sep 2021 09:38:55 +0100 Subject: [PATCH 2/3] Bump Model Fragments --- package.json | 2 +- tests/unit/shared-adapter-behaviour.js | 7 ++----- yarn.lock | 29 +++++++++++++------------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index a194d16a..5a9c5b90 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "ember-cli-sri": "^2.1.1", "ember-cli-terser": "^4.0.2", "ember-data": "~3.24", - "ember-data-model-fragments": "^4.0.0", + "ember-data-model-fragments": "^5.0.0-beta.2", "ember-disable-prototype-extensions": "^1.1.3", "ember-django-adapter": "^2.1.1", "ember-fetch": "^7.0.0", diff --git a/tests/unit/shared-adapter-behaviour.js b/tests/unit/shared-adapter-behaviour.js index a4db8beb..a323acee 100644 --- a/tests/unit/shared-adapter-behaviour.js +++ b/tests/unit/shared-adapter-behaviour.js @@ -74,15 +74,12 @@ SharedBehavior.mockFindRecordCommonTests = function () { }); test('returns id fails with 404 if record for id and model type not found in store', async function (assert) { - assert.expect(1); let profileId = 1; mockFindRecord('profile').returns({ id: profileId }); - try { - await FactoryGuy.store.findRecord('profile', profileId); - } catch (reason) { + await FactoryGuy.store.findRecord('profile', profileId).catch((reason) => { assert.equal(reason.errors[0].status, '404'); - } + }); }); // test("returns model succeeds", async function(assert) { diff --git a/yarn.lock b/yarn.lock index 18435ff0..c538714e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4854,7 +4854,7 @@ ember-cli-babel-plugin-helpers@^1.0.0, ember-cli-babel-plugin-helpers@^1.1.1: resolved "https://registry.yarnpkg.com/ember-cli-babel-plugin-helpers/-/ember-cli-babel-plugin-helpers-1.1.1.tgz#5016b80cdef37036c4282eef2d863e1d73576879" integrity sha512-sKvOiPNHr5F/60NLd7SFzMpYPte/nnGkq/tMIfXejfKHIhaiIkYFqX8Z9UFTKWLLn+V7NOaby6niNPZUdvKCRw== -ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.16.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.0, ember-cli-babel@^6.8.2: +ember-cli-babel@^6.0.0, ember-cli-babel@^6.0.0-beta.4, ember-cli-babel@^6.16.0, ember-cli-babel@^6.6.0, ember-cli-babel@^6.8.2: version "6.18.0" resolved "https://registry.yarnpkg.com/ember-cli-babel/-/ember-cli-babel-6.18.0.tgz#3f6435fd275172edeff2b634ee7b29ce74318957" integrity sha512-7ceC8joNYxY2wES16iIBlbPSxwKDBhYwC8drU3ZEvuPDMwVv1KzxCNu1fvxyFEBWhwaRNTUxSCsEVoTd9nosGA== @@ -5223,24 +5223,25 @@ ember-compatibility-helpers@^1.1.1, ember-compatibility-helpers@^1.1.2, ember-co fs-extra "^9.1.0" semver "^5.4.1" -ember-copy@1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/ember-copy/-/ember-copy-1.0.0.tgz#426554ba6cf65920f31d24d0a3ca2cb1be16e4aa" - integrity sha512-aiZNAvOmdemHdvZNn0b5b/0d9g3JFpcOsrDgfhYEbfd7SzE0b69YiaVK2y3wjqfjuuiA54vOllGN4pjSzECNSw== +ember-copy@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/ember-copy/-/ember-copy-2.0.1.tgz#13192b12a250324bb4a8b4547a680b113f4e3041" + integrity sha512-N/XFvZszrzyyX4IcNoeK4mJvIItNuONumhPLqi64T8NDjJkxBj4Pq61rvMkJx/9eZ8alzE4I8vYKOLxT0FvRuQ== dependencies: - ember-cli-babel "^6.6.0" + ember-cli-babel "^7.22.1" -ember-data-model-fragments@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/ember-data-model-fragments/-/ember-data-model-fragments-4.0.0.tgz#8570d8b6bef12e8a3518279af01478ef8818a44f" - integrity sha512-DcRRQAWrrfRQBW8+v6takQdS2hNJ9rKWU/uHjnPY6+Vg/y6TxyPU8mo0PF2z0DYAeXwoIQ05iYTJT0sqFPEo+w== +ember-data-model-fragments@^5.0.0-beta.2: + version "5.0.0-beta.2" + resolved "https://registry.yarnpkg.com/ember-data-model-fragments/-/ember-data-model-fragments-5.0.0-beta.2.tgz#cc5f6e37363216a227394b31beb8eecc4c267a3e" + integrity sha512-LMObs51btOpHFX0DABReU68hpzkZp/yCKCh5w6CSGEm7MM5Bcj8p7Wb4GQIPZANKidVSvdCOT4qnyCREyUatBg== dependencies: broccoli-file-creator "^2.1.1" broccoli-merge-trees "^3.0.0" calculate-cache-key-for-tree "^1.1.0" - ember-cli-babel "^6.8.0" - ember-copy "1.0.0" - git-repo-info "^2.0.0" + ember-cli-babel "^7.23.0" + ember-compatibility-helpers "^1.2.1" + ember-copy "2.0.1" + git-repo-info "^2.1.1" npm-git-info "^1.0.3" ember-data@3.24.2, ember-data@~3.24: @@ -6734,7 +6735,7 @@ git-read-pkt-line@0.0.8: bops "0.0.3" through "~2.2.7" -git-repo-info@^2.0.0, git-repo-info@^2.1.1: +git-repo-info@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/git-repo-info/-/git-repo-info-2.1.1.tgz#220ffed8cbae74ef8a80e3052f2ccb5179aed058" integrity sha512-8aCohiDo4jwjOwma4FmYFd3i97urZulL8XL24nIPxuE+GZnfsAyy/g2Shqx6OjUiFKUXZM+Yy+KHnOmmA3FVcg== From c133c454a3b54cbdf460d41679d6f4c306f739e2 Mon Sep 17 00:00:00 2001 From: Pat O'Callaghan Date: Wed, 29 Sep 2021 14:04:07 +0100 Subject: [PATCH 3/3] Make Factory Guy compatible with Model Fragments & Ember Data 3.16+ --- addon/converter/fixture-converter.js | 32 ++++++++++++++++++++ tests/unit/shared-factory-guy-behaviour.js | 35 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/addon/converter/fixture-converter.js b/addon/converter/fixture-converter.js index c96713b8..34140010 100644 --- a/addon/converter/fixture-converter.js +++ b/addon/converter/fixture-converter.js @@ -3,6 +3,8 @@ import { entries } from '../utils/helper-functions'; import { typeOf } from '@ember/utils'; import { getOwner } from '@ember/application'; import { camelize } from '@ember/string'; +import Fragment from 'ember-data-model-fragments/fragment'; +import FragmentArray from 'ember-data-model-fragments/array/fragment'; /** Base class for converting the base fixture that factory guy creates to @@ -185,6 +187,18 @@ export default class FixtureConverter { let attributeKey = transformKeyFunction(attribute), transformValueFunction = this.getTransformValueFunction(meta.type); + let attributeValueInFixture = fixture[attributeKey]; + + // If passed Fragments or FragmentArrays we must transform them to their serialized form before we can push them into the Store + if ( + attributeValueInFixture instanceof Fragment || + attributeValueInFixture instanceof FragmentArray + ) { + fixture[attributeKey] = this.normalizeModelFragments( + attributeValueInFixture + ); + } + if (Object.prototype.hasOwnProperty.call(fixture, attribute)) { attributes[attributeKey] = transformValueFunction( fixture[attribute], @@ -203,6 +217,24 @@ export default class FixtureConverter { return attributes; } + normalizeModelFragments(attributeValueInFixture) { + if (attributeValueInFixture instanceof Fragment) { + return this.store.normalize( + attributeValueInFixture.constructor.modelName, + attributeValueInFixture.serialize() + ).data.attributes; + } + if (attributeValueInFixture instanceof FragmentArray) { + return attributeValueInFixture + .serialize() + .map( + (item) => + this.store.normalize(attributeValueInFixture.type, item).data + .attributes + ); + } + } + /** Extract relationships and descend into those looking for others diff --git a/tests/unit/shared-factory-guy-behaviour.js b/tests/unit/shared-factory-guy-behaviour.js index b139e3e2..e3cabf7e 100644 --- a/tests/unit/shared-factory-guy-behaviour.js +++ b/tests/unit/shared-factory-guy-behaviour.js @@ -300,6 +300,41 @@ SharedBehavior.makeTests = function () { assert.ok(lastHat.get('outfit.hats.firstObject') === lastHat); }); + test('handles fragment relationships', function (assert) { + let name = make('name', {}); + + let employee = make('employee', { name }); + assert.equal( + employee.name.firstName, + name.firstName, + 'fragment name.firstName' + ); + assert.equal( + employee.name.lastName, + name.lastName, + 'fragment name.lastName' + ); + }); + + test('handles fragmentArray relationships', function (assert) { + let departmentEmployments = make( + 'employee', + 'with_department_employments' + ).departmentEmployments; + + let employee = make('employee', { departmentEmployments }); + assert.equal( + employee.departmentEmployments.firstObject.department.name, + departmentEmployments.firstObject.department.name, + 'fragment array - first department name' + ); + assert.equal( + employee.departmentEmployments.lastObject.department.name, + departmentEmployments.lastObject.department.name, + 'fragment array - last department name' + ); + }); + test('using afterMake with transient attributes in definition', function (assert) { run(function () { let property = FactoryGuy.make('property');