Skip to content

Commit

Permalink
Updated users to have html link
Browse files Browse the repository at this point in the history
  • Loading branch information
bp-cos committed Aug 28, 2023
1 parent b9ec4dd commit e7c9927
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const Validations = buildValidations({
});

export interface UserLinks extends OsfLinks {
html: Link;
profile_image: Link; // eslint-disable-line camelcase
}

Expand Down
5 changes: 4 additions & 1 deletion mirage/factories/preprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export default Factory.extend<PreprintModel>({
afterCreate(newPreprint, server) {
guidAfterCreate(newPreprint, server);

const contributorUser = server.create('user');
const contributorUser = server.create('user', {
givenName: 'Emmit',
familyName: 'Stud',
});

const contributor = server.create('contributor', {
preprint: newPreprint,
Expand Down
15 changes: 8 additions & 7 deletions mirage/serializers/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import ApplicationSerializer, { SerializedRelationships } from './application';
const { OSF: { apiUrl } } = config;

export default class UserSerializer extends ApplicationSerializer<User> {
buildNormalLinks(model: ModelInstance<User>) {
return {
...super.buildNormalLinks(model),
profile_image: randomGravatar(),
html: randomGravatar(),
};
}

buildRelationships(model: ModelInstance<User>) {
const serializedRelationships: SerializedRelationships<User> = {
emails: {
Expand Down Expand Up @@ -75,11 +83,4 @@ export default class UserSerializer extends ApplicationSerializer<User> {
}
return serializedRelationships;
}

buildNormalLinks(model: ModelInstance<User>) {
return {
...super.buildNormalLinks(model),
profile_image: randomGravatar(),
};
}
}

0 comments on commit e7c9927

Please sign in to comment.