Skip to content

Commit

Permalink
chore(ember/mirage): added maintainers and users
Browse files Browse the repository at this point in the history
  • Loading branch information
c0rydoras committed Oct 30, 2023
1 parent 35b0bc9 commit 1af67dc
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ember/mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ function routes() {
this.passthrough('https://outdated.local/auth/**');

this.namespace = '/api';
this.resource('maintainers');
this.resource('users');
this.resource('projects');
this.resource('versions');
this.resource('release-versions');
Expand Down
7 changes: 7 additions & 0 deletions ember/mirage/factories/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Factory, belongsTo } from 'miragejs';

export default Factory.extend({
project: belongsTo(),
user: belongsTo(),
isPrimary: (index) => index === 0,
});
17 changes: 17 additions & 0 deletions ember/mirage/factories/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,21 @@ export default Factory.extend({
});
},
}),
withMaintainers: trait({
afterCreate(project, server) {
project.update({
maintainers: [
server.create('maintainer', {
user: server.create('user'),
project,
isPrimary: true,
}),
server.create('maintainer', {
user: server.create('user'),
project,
}),
],
});
},
}),
});
8 changes: 6 additions & 2 deletions ember/mirage/factories/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export default Factory.extend({
idpId: () => faker.string.uuid,
firstName: () => faker.person.firstName(),
lastName: () => faker.person.lastName(),
email: () => faker.internet.email(),
username: () => faker.internet.userName(),
email() {
return `${this.firstName}.${this.lastName}@example.com`.toLowerCase();
},
username() {
return `${this.firstName}${this.lastName[0]}`.toLowerCase();
},
});
2 changes: 2 additions & 0 deletions ember/mirage/scenarios/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ export default function (server) {
// server.createList('post', 10);
server.createList('project', 3, 'withVersions');
server.createList('project', 1);
server.createList('project', 2, 'withMaintainers', 'withVersions');
server.createList('user', 2);
}

0 comments on commit 1af67dc

Please sign in to comment.