mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 14:43:08 +03:00
Decoupled frontend rss service from the url service
refs https://linear.app/tryghost/issue/CORE-103/decouple-internal-frontend-code-from-url-module - We need to decouple all frontend services from URL service as much as possible. "bootstrap" module is now a central point to substitute (proxy really) function previously done by the URL service and this move changes direct usage of URL service to "bootstraps" internal proxy function
This commit is contained in:
parent
add30f3d5b
commit
fead0e3dcf
@ -3,7 +3,7 @@ const Promise = require('bluebird');
|
||||
const cheerio = require('cheerio');
|
||||
const RSS = require('rss');
|
||||
const urlUtils = require('../../../shared/url-utils');
|
||||
const urlService = require('../url');
|
||||
const bootstrap = require('../routing/bootstrap');
|
||||
|
||||
const generateTags = function generateTags(data) {
|
||||
if (data.tags) {
|
||||
@ -19,7 +19,7 @@ const generateTags = function generateTags(data) {
|
||||
};
|
||||
|
||||
const generateItem = function generateItem(post, secure) {
|
||||
const itemUrl = urlService.getUrlByResourceId(post.id, {secure, absolute: true});
|
||||
const itemUrl = bootstrap.internal.getUrlByResourceId(post.id, {secure, absolute: true});
|
||||
const htmlContent = cheerio.load(post.html || '');
|
||||
const item = {
|
||||
title: post.title,
|
||||
|
@ -3,7 +3,7 @@ const sinon = require('sinon');
|
||||
const _ = require('lodash');
|
||||
const testUtils = require('../../../../utils');
|
||||
const configUtils = require('../../../../utils/configUtils');
|
||||
const urlService = require('../../../../../core/frontend/services/url');
|
||||
const bootstrap = require('../../../../../core/frontend/services/routing/bootstrap');
|
||||
const generateFeed = require('../../../../../core/frontend/services/rss/generate-feed');
|
||||
|
||||
describe('RSS: Generate Feed', function () {
|
||||
@ -43,7 +43,7 @@ describe('RSS: Generate Feed', function () {
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
sinon.stub(urlService, 'getUrlByResourceId');
|
||||
sinon.stub(bootstrap.internal, 'getUrlByResourceId');
|
||||
|
||||
baseUrl = '/rss/';
|
||||
|
||||
@ -92,7 +92,7 @@ describe('RSS: Generate Feed', function () {
|
||||
data.posts = posts;
|
||||
|
||||
_.each(data.posts, function (post) {
|
||||
urlService.getUrlByResourceId.withArgs(post.id, {secure: undefined, absolute: true}).returns('http://my-ghost-blog.com/' + post.slug + '/');
|
||||
bootstrap.internal.getUrlByResourceId.withArgs(post.id, {secure: undefined, absolute: true}).returns('http://my-ghost-blog.com/' + post.slug + '/');
|
||||
});
|
||||
|
||||
generateFeed(baseUrl, data).then(function (xmlData) {
|
||||
@ -204,7 +204,7 @@ describe('RSS: Generate Feed', function () {
|
||||
data.posts = [posts[0]];
|
||||
|
||||
_.each(data.posts, function (post) {
|
||||
urlService.getUrlByResourceId.withArgs(post.id, {secure: undefined, absolute: true}).returns('http://my-ghost-blog.com/' + post.slug + '/');
|
||||
bootstrap.internal.getUrlByResourceId.withArgs(post.id, {secure: undefined, absolute: true}).returns('http://my-ghost-blog.com/' + post.slug + '/');
|
||||
});
|
||||
|
||||
generateFeed(baseUrl, data).then(function (xmlData) {
|
||||
|
Loading…
Reference in New Issue
Block a user