Skip to content

Commit

Permalink
Merge pull request #1347 from code-corps/add-models
Browse files Browse the repository at this point in the history
Add models for github installations
  • Loading branch information
joshsmith committed Jul 13, 2017
2 parents 3e398eb + 5393597 commit 1078f2f
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 0 deletions.
16 changes: 16 additions & 0 deletions 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 })
});
16 changes: 16 additions & 0 deletions 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 })
});
11 changes: 11 additions & 0 deletions 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 })
});
11 changes: 11 additions & 0 deletions 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 })
});
1 change: 1 addition & 0 deletions app/models/project.js
Expand Up @@ -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 }),
Expand Down
8 changes: 8 additions & 0 deletions 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()
});
5 changes: 5 additions & 0 deletions mirage/models/github-repo.js
@@ -0,0 +1,5 @@
import { Model, belongsTo } from 'ember-cli-mirage';

export default Model.extend({
githubAppInstallation: belongsTo()
});
6 changes: 6 additions & 0 deletions 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()
});
6 changes: 6 additions & 0 deletions 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()
});
32 changes: 32 additions & 0 deletions 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');
29 changes: 29 additions & 0 deletions 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');
25 changes: 25 additions & 0 deletions 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');
25 changes: 25 additions & 0 deletions 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');
2 changes: 2 additions & 0 deletions tests/unit/models/project-test.js
Expand Up @@ -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',
Expand All @@ -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');
Expand Down

0 comments on commit 1078f2f

Please sign in to comment.