Switched to bookshelf repository

This commit is contained in:
Fabien "egg" O'Carroll 2023-06-28 23:25:08 +01:00 committed by naz
parent 4ffdab3c82
commit 2808df7f87
2 changed files with 7 additions and 5 deletions

View File

@ -1,7 +1,7 @@
const {
CollectionsService,
CollectionsRepositoryInMemory
CollectionsService
} = require('@tryghost/collections');
const BookshelfCollectionsRepository = require('./BookshelfCollectionsRepository');
const labs = require('../../../shared/labs');
class CollectionsServiceWrapper {
@ -9,9 +9,10 @@ class CollectionsServiceWrapper {
api;
constructor() {
const postsRepository = require('./PostsRepository').getInstance();
const collectionsRepositoryInMemory = new CollectionsRepositoryInMemory();
const DomainEvents = require('@tryghost/domain-events');
const postsRepository = require('./PostsRepository').getInstance();
const models = require('../../models');
const collectionsRepositoryInMemory = new BookshelfCollectionsRepository(models.Collection);
const collectionsService = new CollectionsService({
collectionsRepository: collectionsRepositoryInMemory,
@ -19,7 +20,7 @@ class CollectionsServiceWrapper {
DomainEvents: DomainEvents,
slugService: {
async generate(input) {
return input.toLowerCase().trim().replace(/^[^a-z0-9A-Z_]+/, '').replace(/[^a-z0-9A-Z_]+$/, '').replace(/[^a-z0-9A-Z_]+/g, '-');
return models.Collection.generateSlug(models.Collection, input, {});
}
}
});

View File

@ -88,6 +88,7 @@ describe('Posts API', function () {
let agent;
before(async function () {
mockManager.mockLabsEnabled('collections', true);
agent = await agentProvider.getAdminAPIAgent();
await fixtureManager.init('posts');
await agent.loginAsOwner();