|
1 | | -import { Factory, Trait, trait } from 'ember-cli-mirage'; |
| 1 | +import { Factory, ModelInstance, Trait, trait } from 'ember-cli-mirage'; |
2 | 2 | import faker from 'faker'; |
3 | 3 | import { ReviewActionTrigger } from 'ember-osf-web/models/review-action'; |
4 | 4 |
|
5 | 5 | import PreprintModel from 'ember-osf-web/models/preprint'; |
6 | 6 | import { Permission } from 'ember-osf-web/models/osf-model'; |
7 | 7 | import { ReviewsState } from 'ember-osf-web/models/provider'; |
8 | | - |
| 8 | +import UserModel from 'ember-osf-web/models/user'; |
9 | 9 | import { guid, guidAfterCreate} from './utils'; |
10 | 10 |
|
11 | 11 | function buildLicenseText(): string { |
@@ -170,11 +170,14 @@ export default Factory.extend<PreprintMirageModel & PreprintTraits>({ |
170 | 170 |
|
171 | 171 | isContributor: trait<PreprintModel>({ |
172 | 172 | afterCreate(preprint, server) { |
173 | | - const { currentUserId } = server.schema.roots.first(); |
174 | | - server.create('contributor', { |
| 173 | + const contributors = preprint.contributors.models; |
| 174 | + const firstContributor = server.create('contributor', { |
175 | 175 | preprint, |
176 | | - id: currentUserId, |
| 176 | + index:0, |
| 177 | + users: server.schema.roots.first().currentUser as ModelInstance<UserModel>, |
177 | 178 | }); |
| 179 | + contributors.splice(0,1,firstContributor); |
| 180 | + preprint.update({ contributors, bibliographicContributors:contributors }); |
178 | 181 | }, |
179 | 182 | }), |
180 | 183 |
|
|
0 commit comments