Icu 6896 upgrade ember data (#1511)
* chore: 🤖 Upgrade ember data to 3.28.12 ✅ Closes: ICU-6896
This commit is contained in:
1 parent
764f4703e0
commit
8ae6506abf
12 files changed
+168
-158
No files matched your search
@@ -54,6 +54,10 @@ export default class BaseModel extends Model {
|
||||
const id = this.scopeID;
|
||||
return this.store.peekRecord('scope', id);
|
||||
}
|
||||
|
||||
// Ember seems to have a bug with its internals and can't correctly set
|
||||
// the `scopeModel` when passed in as part of the `inputProperties`
|
||||
// of a `createRecord` call
|
||||
set scopeModel(model) {
|
||||
if (model) {
|
||||
const json = model.serialize();
|
||||
@@ -92,7 +96,6 @@ export default class BaseModel extends Model {
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('hasDirtyAttributes', 'isSaving')
|
||||
get canSave() {
|
||||
return this.hasDirtyAttributes && !this.isSaving;
|
||||
}
|
||||
@@ -100,7 +103,6 @@ export default class BaseModel extends Model {
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
@computed('canSave')
|
||||
get cannotSave() {
|
||||
return !this.canSave;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"ember-cli-htmlbars": "^6.1.0",
|
||||
"ember-cli-mirage": "^2.2.0",
|
||||
"ember-copy": "^2.0.1",
|
||||
"ember-data": "^3.20.0",
|
||||
"ember-data": "^3.28.12",
|
||||
"ember-fetch": "^8.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -68,8 +68,8 @@ module('Unit | Model | base', function (hooks) {
|
||||
assert.strictEqual(model.displayName, 'Test');
|
||||
});
|
||||
|
||||
test('it has canSave and cannotSave attributes', function (assert) {
|
||||
assert.expect(8);
|
||||
test('it has canSave and cannotSave attributes', async function (assert) {
|
||||
assert.expect(11);
|
||||
const store = this.owner.lookup('service:store');
|
||||
store.push({
|
||||
data: {
|
||||
@@ -78,20 +78,32 @@ module('Unit | Model | base', function (hooks) {
|
||||
attributes: {},
|
||||
},
|
||||
});
|
||||
this.server.patch('/v1/users/1', () => {
|
||||
assert.ok(true, 'Correctly scoped update record URL was requested.');
|
||||
return {};
|
||||
});
|
||||
const model = store.peekRecord('user', '1');
|
||||
assert.false(model.canSave);
|
||||
assert.true(model.cannotSave);
|
||||
// Should be able to save if dirty
|
||||
model.name = 'User';
|
||||
|
||||
assert.true(model.hasDirtyAttributes);
|
||||
assert.true(model.canSave);
|
||||
assert.false(model.cannotSave);
|
||||
|
||||
// Should not be able to save while currently saving
|
||||
model.transitionTo('updated.inFlight');
|
||||
const savePromise = model.save();
|
||||
|
||||
// Verify conditions before save completes
|
||||
assert.true(model.isSaving);
|
||||
assert.false(model.canSave);
|
||||
assert.true(model.cannotSave);
|
||||
model.transitionTo('loaded');
|
||||
|
||||
// Verify conditions after save completes
|
||||
await savePromise;
|
||||
assert.false(model.isSaving);
|
||||
assert.false(model.canSave);
|
||||
});
|
||||
|
||||
test('it saves records to a scoped URL', async function (assert) {
|
||||
|
||||
Reference in new issue
Block a user