diff --git a/app/models/github-app-installation.js b/app/models/github-app-installation.js new file mode 100644 index 000000000..937234934 --- /dev/null +++ b/app/models/github-app-installation.js @@ -0,0 +1,16 @@ +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; +import { belongsTo, hasMany } from 'ember-data/relationships'; + +export default Model.extend({ + githubId: attr(), + insertedAt: attr(), + installed: attr(), + state: attr(), + updatedAt: attr(), + + githubRepos: hasMany('github-repo', { async: true }), + organizationGithubAppInstallations: hasMany('organization-github-app-installation', { async: true }), + project: belongsTo('project', { async: true }), + user: belongsTo('user', { async: true }) +}); diff --git a/app/models/github-repo.js b/app/models/github-repo.js new file mode 100644 index 000000000..767079c62 --- /dev/null +++ b/app/models/github-repo.js @@ -0,0 +1,16 @@ +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; +import { belongsTo } from 'ember-data/relationships'; + +export default Model.extend({ + githubAccountAvatarUrl: attr(), + githubAccountId: attr(), + githubAccountLogin: attr(), + githubAccountType: attr(), + githubId: attr(), + insertedAt: attr(), + name: attr(), + updatedAt: attr(), + + githubAppInstallation: belongsTo('github-app-installation', { async: true }) +}); diff --git a/app/models/organization-github-app-installation.js b/app/models/organization-github-app-installation.js new file mode 100644 index 000000000..727645a22 --- /dev/null +++ b/app/models/organization-github-app-installation.js @@ -0,0 +1,11 @@ +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; +import { belongsTo } from 'ember-data/relationships'; + +export default Model.extend({ + insertedAt: attr(), + updatedAt: attr(), + + githubAppInstallation: belongsTo('github-app-installation', { async: true }), + organization: belongsTo('organization', { async: true }) +}); diff --git a/app/models/project-github-repo.js b/app/models/project-github-repo.js new file mode 100644 index 000000000..67866dad9 --- /dev/null +++ b/app/models/project-github-repo.js @@ -0,0 +1,11 @@ +import Model from 'ember-data/model'; +import attr from 'ember-data/attr'; +import { belongsTo } from 'ember-data/relationships'; + +export default Model.extend({ + insertedAt: attr(), + updatedAt: attr(), + + githubRepo: belongsTo('github-repo', { async: true }), + project: belongsTo('project', { async: true }) +}); diff --git a/app/models/project.js b/app/models/project.js index 0579768ff..54768900f 100644 --- a/app/models/project.js +++ b/app/models/project.js @@ -29,6 +29,7 @@ export default Model.extend({ taskLists: hasMany('task-list', { async: true }), tasks: hasMany('tasks', { async: true }), projectCategories: hasMany('project-category', { async: true }), + projectGithubRepos: hasMany('project-github-repo', { async: true }), projectSkills: hasMany('project-skill', { async: true }), projectUsers: hasMany('project-user', { async: true }), stripeConnectPlan: belongsTo('stripe-connect-plan', { async: true }), diff --git a/mirage/models/github-app-installation.js b/mirage/models/github-app-installation.js new file mode 100644 index 000000000..d38c274e1 --- /dev/null +++ b/mirage/models/github-app-installation.js @@ -0,0 +1,8 @@ +import { Model, belongsTo, hasMany } from 'ember-cli-mirage'; + +export default Model.extend({ + githubRepos: hasMany(), + organizationGithubAppInstallations: hasMany(), + project: belongsTo(), + user: belongsTo() +}); diff --git a/mirage/models/github-repo.js b/mirage/models/github-repo.js new file mode 100644 index 000000000..abe5ab466 --- /dev/null +++ b/mirage/models/github-repo.js @@ -0,0 +1,5 @@ +import { Model, belongsTo } from 'ember-cli-mirage'; + +export default Model.extend({ + githubAppInstallation: belongsTo() +}); diff --git a/mirage/models/organization-github-app-installation.js b/mirage/models/organization-github-app-installation.js new file mode 100644 index 000000000..639648a2c --- /dev/null +++ b/mirage/models/organization-github-app-installation.js @@ -0,0 +1,6 @@ +import { Model, belongsTo } from 'ember-cli-mirage'; + +export default Model.extend({ + githubAppInstallation: belongsTo(), + organization: belongsTo() +}); diff --git a/mirage/models/project-github-repo.js b/mirage/models/project-github-repo.js new file mode 100644 index 000000000..2a3d93c46 --- /dev/null +++ b/mirage/models/project-github-repo.js @@ -0,0 +1,6 @@ +import { Model, belongsTo } from 'ember-cli-mirage'; + +export default Model.extend({ + githubRepo: belongsTo(), + project: belongsTo() +}); diff --git a/tests/unit/models/github-app-installation-test.js b/tests/unit/models/github-app-installation-test.js new file mode 100644 index 000000000..00015b548 --- /dev/null +++ b/tests/unit/models/github-app-installation-test.js @@ -0,0 +1,32 @@ +import { moduleForModel, test } from 'ember-qunit'; +import { testForBelongsTo, testForHasMany } from '../../helpers/relationship'; +import { testForAttributes } from 'code-corps-ember/tests/helpers/attributes'; +import '../../helpers/has-attributes'; + +moduleForModel('github-app-installation', 'Unit | Model | github-app-installation', { + // Specify the other units that are required for this test. + needs: [ + 'model:github-repo', + 'model:organization-github-app-installation', + 'model:project', + 'model:user' + ] +}); + +test('it exists', function(assert) { + let model = this.subject(); + assert.ok(!!model); +}); + +testForAttributes('github-app-installation', [ + 'githubId', + 'insertedAt', + 'installed', + 'state', + 'updatedAt' +]); + +testForHasMany('github-app-installation', 'organizationGithubAppInstallations'); +testForBelongsTo('github-app-installation', 'project'); +testForBelongsTo('github-app-installation', 'user'); +testForHasMany('github-app-installation', 'githubRepos'); diff --git a/tests/unit/models/github-repo-test.js b/tests/unit/models/github-repo-test.js new file mode 100644 index 000000000..3b33703a7 --- /dev/null +++ b/tests/unit/models/github-repo-test.js @@ -0,0 +1,29 @@ +import { moduleForModel, test } from 'ember-qunit'; +import { testForBelongsTo } from '../../helpers/relationship'; +import { testForAttributes } from 'code-corps-ember/tests/helpers/attributes'; +import '../../helpers/has-attributes'; + +moduleForModel('github-repo', 'Unit | Model | github-repo', { + // Specify the other units that are required for this test. + needs: [ + 'model:github-app-installation' + ] +}); + +test('it exists', function(assert) { + let model = this.subject(); + assert.ok(!!model); +}); + +testForAttributes('github-repo', [ + 'githubAccountAvatarUrl', + 'githubAccountId', + 'githubAccountLogin', + 'githubAccountType', + 'githubId', + 'insertedAt', + 'name', + 'updatedAt' +]); + +testForBelongsTo('github-repo', 'githubAppInstallation'); diff --git a/tests/unit/models/organization-github-app-installation-test.js b/tests/unit/models/organization-github-app-installation-test.js new file mode 100644 index 000000000..f2bbb616b --- /dev/null +++ b/tests/unit/models/organization-github-app-installation-test.js @@ -0,0 +1,25 @@ +import { moduleForModel, test } from 'ember-qunit'; +import { testForBelongsTo } from '../../helpers/relationship'; +import { testForAttributes } from 'code-corps-ember/tests/helpers/attributes'; +import '../../helpers/has-attributes'; + +moduleForModel('organization-github-app-installation', 'Unit | Model | organization-github-app-installation', { + // Specify the other units that are required for this test. + needs: [ + 'model:github-app-installation', + 'model:organization' + ] +}); + +test('it exists', function(assert) { + let model = this.subject(); + assert.ok(!!model); +}); + +testForAttributes('organization-github-app-installation', [ + 'insertedAt', + 'updatedAt' +]); + +testForBelongsTo('organization-github-app-installation', 'githubAppInstallation'); +testForBelongsTo('organization-github-app-installation', 'organization'); diff --git a/tests/unit/models/project-github-repo-test.js b/tests/unit/models/project-github-repo-test.js new file mode 100644 index 000000000..483700e66 --- /dev/null +++ b/tests/unit/models/project-github-repo-test.js @@ -0,0 +1,25 @@ +import { moduleForModel, test } from 'ember-qunit'; +import { testForBelongsTo } from '../../helpers/relationship'; +import { testForAttributes } from 'code-corps-ember/tests/helpers/attributes'; +import '../../helpers/has-attributes'; + +moduleForModel('project-github-repo', 'Unit | Model | project-github-repo', { + // Specify the other units that are required for this test. + needs: [ + 'model:github-repo', + 'model:project' + ] +}); + +test('it exists', function(assert) { + let model = this.subject(); + assert.ok(!!model); +}); + +testForAttributes('project-github-repo', [ + 'insertedAt', + 'updatedAt' +]); + +testForBelongsTo('project-github-repo', 'githubRepo'); +testForBelongsTo('project-github-repo', 'project'); diff --git a/tests/unit/models/project-test.js b/tests/unit/models/project-test.js index 61cc20a1c..db7e4cc74 100644 --- a/tests/unit/models/project-test.js +++ b/tests/unit/models/project-test.js @@ -13,6 +13,7 @@ moduleForModel('project', 'Unit | Model | project', { 'model:donation-goal', 'model:organization', 'model:project-category', + 'model:project-github-repo', 'model:project-skill', 'model:project-user', 'model:stripe-connect-account', @@ -39,6 +40,7 @@ testForBelongsTo('project', 'stripeConnectPlan'); testForHasMany('project', 'donationGoals'); testForHasMany('project', 'projectCategories'); +testForHasMany('project', 'projectGithubRepos'); testForHasMany('project', 'projectSkills'); testForHasMany('project', 'projectUsers'); testForHasMany('project', 'taskLists');