From 096d125f163ef3c14e9e46bda4bd0356c1be68e8 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 17 Jun 2020 18:00:38 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20add=20organization=20an?= =?UTF-8?q?d=20auth=20method=20models?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/api/addon/adapters/auth-method.js | 16 ++++++++ .../api/addon/generated/models/auth-method.js | 37 +++++++++++++++++++ .../addon/generated/models/organization.js | 33 +++++++++++++++++ addons/api/addon/models/auth-method.js | 3 ++ addons/api/addon/models/organization.js | 3 ++ addons/api/app/adapters/auth-method.js | 1 + addons/api/app/models/auth-method.js | 1 + addons/api/app/models/organization.js | 1 + .../tests/unit/adapters/auth-method-test.js | 16 ++++++++ .../api/tests/unit/models/auth-method-test.js | 13 +++++++ .../tests/unit/models/organization-test.js | 13 +++++++ 11 files changed, 137 insertions(+) create mode 100644 addons/api/addon/adapters/auth-method.js create mode 100644 addons/api/addon/generated/models/auth-method.js create mode 100644 addons/api/addon/generated/models/organization.js create mode 100644 addons/api/addon/models/auth-method.js create mode 100644 addons/api/addon/models/organization.js create mode 100644 addons/api/app/adapters/auth-method.js create mode 100644 addons/api/app/models/auth-method.js create mode 100644 addons/api/app/models/organization.js create mode 100644 addons/api/tests/unit/adapters/auth-method-test.js create mode 100644 addons/api/tests/unit/models/auth-method-test.js create mode 100644 addons/api/tests/unit/models/organization-test.js diff --git a/addons/api/addon/adapters/auth-method.js b/addons/api/addon/adapters/auth-method.js new file mode 100644 index 000000000..2da687841 --- /dev/null +++ b/addons/api/addon/adapters/auth-method.js @@ -0,0 +1,16 @@ +import ApplicationAdapter from './application'; +import ScopeAdapterMixin from '../mixins/scope-adapter'; + +export default class AuthMethodAdapter extends ApplicationAdapter.extend( + ScopeAdapterMixin +) { + + // =attributes + + /** + * Auth method is scoped to org only. + * @type {boolean} + */ + includeProject = false; + +} diff --git a/addons/api/addon/generated/models/auth-method.js b/addons/api/addon/generated/models/auth-method.js new file mode 100644 index 000000000..c006b935c --- /dev/null +++ b/addons/api/addon/generated/models/auth-method.js @@ -0,0 +1,37 @@ +import BaseModel from '../../models/base'; +import { attr } from '@ember-data/model'; + +/** + * + */ +export default class GeneratedOrganizationModel extends BaseModel { + + // =attributes + + @attr('string', { + description: 'The type of the resource, to help differentiate schemas' + }) type; + + @attr('string', { + description: 'Optional name for identification purposes', + }) + name; + + @attr('string', { + description: 'Optional user-set description for identification purposes', + }) + description; + + @attr('date', { + description: 'The time this resource was created\nOutput only.', + readOnly: true, + }) + created_time; + + @attr('date', { + description: 'The time this resource was last updated\nOutput only.', + readOnly: true, + }) + updated_time; + +} diff --git a/addons/api/addon/generated/models/organization.js b/addons/api/addon/generated/models/organization.js new file mode 100644 index 000000000..773afb70f --- /dev/null +++ b/addons/api/addon/generated/models/organization.js @@ -0,0 +1,33 @@ +import BaseModel from '../../models/base'; +import { attr } from '@ember-data/model'; + +/** + * + */ +export default class GeneratedOrganizationModel extends BaseModel { + + // =attributes + + @attr('string', { + description: 'Optional name for identification purposes', + }) + name; + + @attr('string', { + description: 'Optional user-set description for identification purposes', + }) + description; + + @attr('date', { + description: 'The time this resource was created\nOutput only.', + readOnly: true, + }) + created_time; + + @attr('date', { + description: 'The time this resource was last updated\nOutput only.', + readOnly: true, + }) + updated_time; + +} diff --git a/addons/api/addon/models/auth-method.js b/addons/api/addon/models/auth-method.js new file mode 100644 index 000000000..ad795fd7d --- /dev/null +++ b/addons/api/addon/models/auth-method.js @@ -0,0 +1,3 @@ +import GeneratedAuthMethodModel from '../generated/models/auth-method'; + +export default class AuthMethodModel extends GeneratedAuthMethodModel {} diff --git a/addons/api/addon/models/organization.js b/addons/api/addon/models/organization.js new file mode 100644 index 000000000..a9478f967 --- /dev/null +++ b/addons/api/addon/models/organization.js @@ -0,0 +1,3 @@ +import GeneratedOrganizationModel from '../generated/models/organization'; + +export default class OrganizationModel extends GeneratedOrganizationModel {} diff --git a/addons/api/app/adapters/auth-method.js b/addons/api/app/adapters/auth-method.js new file mode 100644 index 000000000..02c325d6e --- /dev/null +++ b/addons/api/app/adapters/auth-method.js @@ -0,0 +1 @@ +export { default } from 'api/adapters/auth-method'; diff --git a/addons/api/app/models/auth-method.js b/addons/api/app/models/auth-method.js new file mode 100644 index 000000000..7dfb3b20c --- /dev/null +++ b/addons/api/app/models/auth-method.js @@ -0,0 +1 @@ +export { default } from 'api/models/auth-method'; diff --git a/addons/api/app/models/organization.js b/addons/api/app/models/organization.js new file mode 100644 index 000000000..f9e7429d3 --- /dev/null +++ b/addons/api/app/models/organization.js @@ -0,0 +1 @@ +export { default } from 'api/models/organization'; diff --git a/addons/api/tests/unit/adapters/auth-method-test.js b/addons/api/tests/unit/adapters/auth-method-test.js new file mode 100644 index 000000000..d7c2f176c --- /dev/null +++ b/addons/api/tests/unit/adapters/auth-method-test.js @@ -0,0 +1,16 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; +import config from 'ember-get-config'; + +module('Unit | Adapter | auth method', function (hooks) { + setupTest(hooks); + + test('it generates URL prefixes without project scope', function (assert) { + assert.expect(1); + const service = this.owner.lookup('service:scope'); + service.org = { id: 1 }; + service.project = { id: 2 }; + const adapter = this.owner.lookup('adapter:auth-method'); + assert.equal(adapter.urlPrefix(), `${config.api.namespace}/orgs/1`); + }); +}); diff --git a/addons/api/tests/unit/models/auth-method-test.js b/addons/api/tests/unit/models/auth-method-test.js new file mode 100644 index 000000000..3de95883a --- /dev/null +++ b/addons/api/tests/unit/models/auth-method-test.js @@ -0,0 +1,13 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Model | auth method', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let store = this.owner.lookup('service:store'); + let model = store.createRecord('auth-method', {}); + assert.ok(model); + }); +}); diff --git a/addons/api/tests/unit/models/organization-test.js b/addons/api/tests/unit/models/organization-test.js new file mode 100644 index 000000000..9d94b9ea4 --- /dev/null +++ b/addons/api/tests/unit/models/organization-test.js @@ -0,0 +1,13 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Model | organization', function(hooks) { + setupTest(hooks); + + // Replace this with your real tests. + test('it exists', function(assert) { + let store = this.owner.lookup('service:store'); + let model = store.createRecord('organization', {}); + assert.ok(model); + }); +});