Skip to content

Commit 0a72e74

Browse files
committed
mirage/serializers: Allow factories to override the crates_cnt property
Otherwise we'd have to generate thousands of crates if we want to test the rendering of such a big number
1 parent 24cf819 commit 0a72e74

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

mirage/serializers/category.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ export default BaseSerializer.extend({
1919
let allCrates = this.schema.crates.all();
2020
let associatedCrates = allCrates.filter(it => it.categoryIds.includes(hash.id));
2121

22-
hash.crates_cnt = associatedCrates.length;
22+
hash.crates_cnt ??= associatedCrates.length;
2323
},
2424
});

mirage/serializers/keyword.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ export default BaseSerializer.extend({
1919
let allCrates = this.schema.crates.all();
2020
let associatedCrates = allCrates.filter(it => it.keywordIds.includes(hash.id));
2121

22-
hash.crates_cnt = associatedCrates.length;
22+
hash.crates_cnt ??= associatedCrates.length;
2323
},
2424
});

0 commit comments

Comments
 (0)