mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Fixed failing tests
refs 5a62253466
- The UrlService was relying on a "hidden" identifier field that was passed along with a router object. Now it's passed as an explicit parameter from the "frontend" to the backend's UrlService
This commit is contained in:
parent
5a62253466
commit
042618fe93
3 changed files with 17 additions and 8 deletions
|
@ -43,7 +43,12 @@ class RouterManager {
|
|||
return;
|
||||
}
|
||||
|
||||
this.urlService.onRouterAddedType(router.filter, router.getResourceType(), router.getPermalinks().getValue());
|
||||
this.urlService.onRouterAddedType(
|
||||
router.identifier,
|
||||
router.filter,
|
||||
router.getResourceType(),
|
||||
router.getPermalinks().getValue()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -179,7 +184,7 @@ class RouterManager {
|
|||
if (collectionRouter.getPermalinks().getValue().match(/:year|:month|:day/)) {
|
||||
debug('handleTimezoneEdit: trigger regeneration');
|
||||
|
||||
this.urlService.onRouterUpdated(collectionRouter);
|
||||
this.urlService.onRouterUpdated(collectionRouter.identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ const EXPANSIONS = [{
|
|||
class UrlGenerator {
|
||||
/**
|
||||
* @param {Object} options
|
||||
* @param {String} options.identifier frontend router ID reference
|
||||
* @param {String} options.filter NQL filter string
|
||||
* @param {String} options.resourceType resource type (e.g. 'posts', 'tags')
|
||||
* @param {String} options.permalink permalink string
|
||||
|
@ -43,7 +44,8 @@ class UrlGenerator {
|
|||
* @param {Object} options.urls instance of the backend URLs (used to store the urls)
|
||||
* @param {Number} options.position an ID of the generator
|
||||
*/
|
||||
constructor({filter, resourceType, permalink, queue, resources, urls, position}) {
|
||||
constructor({identifier, filter, resourceType, permalink, queue, resources, urls, position}) {
|
||||
this.identifier = identifier;
|
||||
this.resourceType = resourceType;
|
||||
this.permalink = permalink;
|
||||
this.queue = queue;
|
||||
|
|
|
@ -81,14 +81,16 @@ class UrlService {
|
|||
|
||||
/**
|
||||
* @description Router was created, connect it with a url generator.
|
||||
* @param {String} identifier frontend router ID reference
|
||||
* @param {String} filter NQL filter
|
||||
* @param {String} resourceType
|
||||
* @param {String} permalink
|
||||
*/
|
||||
onRouterAddedType(filter, resourceType, permalink) {
|
||||
onRouterAddedType(identifier, filter, resourceType, permalink) {
|
||||
debug('Registering route: ', filter, resourceType, permalink);
|
||||
|
||||
let urlGenerator = new UrlGenerator({
|
||||
identifier,
|
||||
filter,
|
||||
resourceType,
|
||||
permalink,
|
||||
|
@ -102,10 +104,10 @@ class UrlService {
|
|||
|
||||
/**
|
||||
* @description Router update handler - regenerates it's resources
|
||||
* @param {ExpressRouter} router
|
||||
* @param {String} identifier router ID linked to the UrlGenerator
|
||||
*/
|
||||
onRouterUpdated(router) {
|
||||
const generator = this.urlGenerators.find(g => g.router.id === router.id);
|
||||
onRouterUpdated(identifier) {
|
||||
const generator = this.urlGenerators.find(g => g.identifier === identifier);
|
||||
generator.regenerateResources();
|
||||
}
|
||||
|
||||
|
@ -264,7 +266,7 @@ class UrlService {
|
|||
let urlGenerator;
|
||||
|
||||
this.urlGenerators.every((_urlGenerator) => {
|
||||
if (_urlGenerator.router.identifier === routerId) {
|
||||
if (_urlGenerator.identifier === routerId) {
|
||||
urlGenerator = _urlGenerator;
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue