• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CenterForOpenScience / ember-osf-web / 16684725173

01 Aug 2025 08:39PM UTC coverage: 67.218% (+0.009%) from 67.209%
16684725173

Pull #2607

github

web-flow
Merge 113b60ca0 into 233ec4fa0
Pull Request #2607: Feature/pbs 25 12

3279 of 5350 branches covered (61.29%)

Branch coverage included in aggregate %.

19 of 26 new or added lines in 7 files covered. (73.08%)

3 existing lines in 2 files now uncovered.

8552 of 12251 relevant lines covered (69.81%)

184.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/app/serializers/collection-submission.ts
1
import DS from 'ember-data';
2
import { Resource } from 'osf-api';
3

4
import isHybridGuid from 'ember-osf-web/utils/is-hybrid-guid';
5

6
import OsfSerializer from './osf-serializer';
7

8
export default class CollectionSubmissionSerializer extends OsfSerializer {
9
    /**
10
     * Guid is an attribute on create
11
     */
12
    serialize(snapshot: DS.Snapshot, options: {}) {
13
        const serialized = super.serialize(snapshot, options);
×
NEW
14
        const { data, data: { relationships } } = serialized;
×
NEW
15
        data.attributes = data.attributes || { };
×
16

17
        data.type = 'collection-submissions';
×
18

19
        if (relationships && 'guid' in relationships) {
×
20
            const { guid } = relationships;
×
21
            if ('data' in guid) {
×
22
                const { data: guidData } = guid;
×
23

24
                if (guidData && 'id' in guidData) {
×
NEW
25
                    data.attributes!.guid = guidData.id;
×
26
                    delete relationships.guid;
×
27
                }
28
            }
29
        }
30

31
        return serialized;
×
32
    }
33

34
    /**
35
     * Collected-Metadata IDs must be combined with the collection ID, so that there are no conflicts in the store
36
     */
37
    extractId(modelClass: 'collection-submissions', resourceHash: Resource) {
38
        const resourceId = super.extractId(modelClass, resourceHash);
70✔
39

40
        if (isHybridGuid(resourceId)) {
70!
41
            return resourceId;
×
42
        }
43

44
        let collectionId = '';
70✔
45
        const { collection } = resourceHash.relationships!;
70✔
46
        if ('data' in collection) {
70!
47
            const { data } = collection;
70✔
48
            if (data && 'id' in data) {
70!
49
                collectionId = data.id;
70✔
50
            }
51
        }
52

53
        return `${resourceId}-${collectionId}`;
70✔
54
    }
55
}
56

57
declare module 'ember-data/types/registries/serializer' {
58
    export default interface SerializerRegistry {
59
        'collection-submission': CollectionSubmissionSerializer;
60
    } // eslint-disable-line semi
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc