fix: 🐛 pass scope_id in scope payload rather than query string
This commit is contained in:
6 files changed
+45
-40
No files matched your search
@@ -16,18 +16,4 @@ module('Unit | Adapter | scope', function(hooks) {
|
||||
assert.equal(prefix, `v1`);
|
||||
});
|
||||
|
||||
test('it generates correct createRecord URLs with a scope_id query parameter', function (assert) {
|
||||
assert.expect(1);
|
||||
this.server.post('/v1/scopes', (schema, { queryParams }) =>{
|
||||
assert.equal(queryParams.scope_id, 'o_1');
|
||||
});
|
||||
const store = this.owner.lookup('service:store');
|
||||
const scope = store.createRecord('scope', {
|
||||
scopeID: 'o_1'
|
||||
});
|
||||
const type = scope.constructor;
|
||||
const snapshot = scope._createSnapshot();
|
||||
const adapter = this.owner.lookup('adapter:scope');
|
||||
adapter.createRecord(store, type, snapshot);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import { module, test } from 'qunit';
|
||||
import { setupTest } from 'ember-qunit';
|
||||
|
||||
module('Unit | Serializer | scope', function(hooks) {
|
||||
setupTest(hooks);
|
||||
|
||||
test('it serializes scope_id into payloads', function (assert) {
|
||||
assert.expect(2);
|
||||
const store = this.owner.lookup('service:store');
|
||||
const serializer = store.serializerFor('scope');
|
||||
serializer.serializeScopeID = true;
|
||||
const record = store.createRecord('scope', {
|
||||
name: 'My Scope',
|
||||
description: 'Foo',
|
||||
type: 'org',
|
||||
scope: {
|
||||
scope_id: 'global',
|
||||
type: 'global'
|
||||
}
|
||||
});
|
||||
const serializedRecord = record.serialize();
|
||||
assert.equal(serializer.serializeScopeID, true);
|
||||
assert.deepEqual(serializedRecord, {
|
||||
name: 'My Scope',
|
||||
description: 'Foo',
|
||||
type: 'org',
|
||||
scope_id: 'global'
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in new issue
Block a user