From 71c763cae9d3b1596f96a744d5bc945957d66021 Mon Sep 17 00:00:00 2001 From: Josh Smith Date: Tue, 11 Jul 2017 12:26:14 -0700 Subject: [PATCH 1/2] Add models for github installations --- app/models/github-app-installation.js | 16 ++++++++++ app/models/github-repo.js | 15 +++++++++ .../organization-github-app-installation.js | 11 +++++++ app/models/project-github-repo.js | 11 +++++++ mirage/models/github-app-installation.js | 8 +++++ mirage/models/github-repo.js | 5 +++ .../organization-github-app-installation.js | 6 ++++ mirage/models/project-github-repo.js | 6 ++++ .../models/github-app-installation-test.js | 32 +++++++++++++++++++ tests/unit/models/github-repo-test.js | 28 ++++++++++++++++ ...ganization-github-app-installation-test.js | 25 +++++++++++++++ tests/unit/models/project-github-repo-test.js | 25 +++++++++++++++ 12 files changed, 188 insertions(+) create mode 100644 app/models/github-app-installation.js create mode 100644 app/models/github-repo.js create mode 100644 app/models/organization-github-app-installation.js create mode 100644 app/models/project-github-repo.js create mode 100644 mirage/models/github-app-installation.js create mode 100644 mirage/models/github-repo.js create mode 100644 mirage/models/organization-github-app-installation.js create mode 100644 mirage/models/project-github-repo.js create mode 100644 tests/unit/models/github-app-installation-test.js create mode 100644 tests/unit/models/github-repo-test.js create mode 100644 tests/unit/models/organization-github-app-installation-test.js create mode 100644 tests/unit/models/project-github-repo-test.js 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..a38f52665 --- /dev/null +++ b/app/models/github-repo.js @@ -0,0 +1,15 @@ +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(), + 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/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..b110fb7f9 --- /dev/null +++ b/tests/unit/models/github-repo-test.js @@ -0,0 +1,28 @@ +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', + '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'); From 53935975e18726627fbccb6a57ceb5eebc657264 Mon Sep 17 00:00:00 2001 From: Josh Smith Date: Tue, 11 Jul 2017 14:52:46 -0700 Subject: [PATCH 2/2] Update github repo and project models --- app/models/github-repo.js | 1 + app/models/project.js | 1 + tests/unit/models/github-repo-test.js | 1 + tests/unit/models/project-test.js | 2 ++ 4 files changed, 5 insertions(+) diff --git a/app/models/github-repo.js b/app/models/github-repo.js index a38f52665..767079c62 100644 --- a/app/models/github-repo.js +++ b/app/models/github-repo.js @@ -9,6 +9,7 @@ export default Model.extend({ githubAccountType: attr(), githubId: attr(), insertedAt: attr(), + name: attr(), updatedAt: attr(), githubAppInstallation: belongsTo('github-app-installation', { 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/tests/unit/models/github-repo-test.js b/tests/unit/models/github-repo-test.js index b110fb7f9..3b33703a7 100644 --- a/tests/unit/models/github-repo-test.js +++ b/tests/unit/models/github-repo-test.js @@ -22,6 +22,7 @@ testForAttributes('github-repo', [ 'githubAccountType', 'githubId', 'insertedAt', + 'name', 'updatedAt' ]); 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');