Merge branch 'develop' into chore-favicon

This commit is contained in:
Susmitha Girumala authored and GitHub committed 2020-10-07 11:43:31 -04:00
commit 98682a320f
6 files changed
+32 -14

No files matched your search

+4 -1
View File
@@ -37,8 +37,11 @@ export default class ApplicationSerializer extends RESTSerializer {
* @param {String} key
* @param {Object} attribute
*/
serializeAttribute(snapshot, json, key, { options }) {
serializeAttribute(snapshot, json, key, attribute) {
const { type, options } = attribute;
let value = super.serializeAttribute(...arguments);
// Convert empty strings to null.
if (type === 'string' && json[key] === '') json[key] = null;
// Do not serialize read-only attributes.
if (options.readOnly) delete json[key];
// Version is sent only if it has a non-nullish value
@@ -70,6 +70,21 @@ module('Unit | Serializer | application', function (hooks) {
});
});
test('it serializes empty strings to null', function (assert) {
assert.expect(1);
const store = this.owner.lookup('service:store');
const record = store.createRecord('user', {
name: '',
description: '',
version: null,
});
let serializedRecord = record.serialize();
assert.deepEqual(serializedRecord, {
name: null,
description: null,
});
});
test('it serializes non-nullish version fields', function (assert) {
assert.expect(2);
const store = this.owner.lookup('service:store');
@@ -1,6 +1,6 @@
<Rose::Form
class="full-width"
@onSubmit={{fn this.submit @submit}}
@onSubmit={{fn this.submit @submit this.currentPassword this.newPassword}}
@cancel={{fn this.cancel @cancel}}
@disabled={{@model.isSaving}}
@error={{@model.errors.base}}
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { computed } from '@ember/object';
import { action } from '@ember/object';
import { next } from '@ember/runloop';
import { run } from '@ember/runloop';
export default class FormAccountPasswordChangePasswordIndexComponent extends Component {
@@ -50,13 +50,13 @@ export default class FormAccountPasswordChangePasswordIndexComponent extends Com
* Call passed submit function with passwords.
* Unset passwords before callack.
* @param {function} fn
* @param {string} currentPassword
* @param {string} newPassword
*/
@action
submit(fn) {
const currentPassword = this.currentPassword;
const newPassword = this.newPassword;
next(() => this.resetPasswords());
fn(currentPassword, newPassword);
submit(fn, currentPassword, newPassword) {
run(() => this.resetPasswords());
run(() => fn(currentPassword, newPassword));
}
/**
@@ -1,5 +1,5 @@
<Rose::Form
@onSubmit={{fn this.submit @submit}}
@onSubmit={{fn this.submit @submit this.password}}
@disabled={{@model.isSaving}}
@error={{@model.errors.base}}
as |form|
@@ -2,7 +2,7 @@ import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { computed } from '@ember/object';
import { action } from '@ember/object';
import { next } from '@ember/runloop';
import { run } from '@ember/runloop';
export default class FormAccountPasswordSetPasswordIndexComponent extends Component {
// =properties
@@ -36,11 +36,11 @@ export default class FormAccountPasswordSetPasswordIndexComponent extends Compon
* Submit with password value when it is allowed.
* Callback with no arguments otherwise.
* @param {function} fn
* @param {string} password
*/
@action
submit(fn) {
const password = this.password;
next(() => this.resetPassword());
fn(password);
submit(fn, password) {
run(() => this.resetPassword());
run(() => fn(password));
}
}