Removed urlFor parameter from UpdateCheckService

refs https://github.com/TryGhost/Team/issues/728

- This is continuation of the previous commit. TLDR: Passing only the necessary API endpoint function makes it easier to reason about what dependencies the UpdateCheckService has to deal with
- Substituted a parameter with already existing 'siteUrl' config value. No need to duplicate work!
This commit is contained in:
Naz 2021-06-02 14:36:53 +04:00
parent 7ce5ab27c3
commit 796e2caaff
2 changed files with 2 additions and 10 deletions

View File

@ -38,14 +38,12 @@ class UpdateCheckService {
* @param {string[]} [options.config.notificationGroups] - example values ["migration", "something"]
* @param {string} options.config.siteUrl - Ghost instance URL
* @param {boolean} [options.config.forceUpdate]
* @param {Function} urlFor - function creating a URL for a certain context
*/
constructor({api, config, i18n, logging, urlFor, request, ghostVersion, ghostMailer}) {
constructor({api, config, i18n, logging, request, ghostVersion, ghostMailer}) {
this.api = api;
this.config = config;
this.i18n = i18n;
this.logging = logging;
this.urlFor = urlFor;
this.request = request;
this.ghostVersion = ghostVersion;
this.ghostMailer = ghostMailer;
@ -106,7 +104,7 @@ class UpdateCheckService {
const users = await this.api.users.browse(internal);
const npm = await Promise.promisify(exec)('npm -v');
const blogUrl = this.urlFor('home', true);
const blogUrl = this.config.siteUrl;
const parsedBlogUrl = url.parse(blogUrl);
const blogId = parsedBlogUrl.hostname + parsedBlogUrl.pathname.replace(/\//, '') + hash.value;

View File

@ -13,7 +13,6 @@ describe('Update Check', function () {
let i18nStub;
let loggingStub;
let requestStub;
let urlForStub;
beforeEach(function () {
settingsStub = sinon.stub().resolves({
@ -67,7 +66,6 @@ describe('Update Check', function () {
},
i18n: i18nStub,
logging: loggingStub,
urlFor: urlForStub,
request: requestStub,
ghostVersion,
ghostMailer: {
@ -131,7 +129,6 @@ describe('Update Check', function () {
},
i18n: i18nStub,
logging: loggingStub,
urlFor: urlForStub,
request: requestStub,
ghostVersion,
ghostMailer: {
@ -181,7 +178,6 @@ describe('Update Check', function () {
},
i18n: i18nStub,
logging: loggingStub,
urlFor: urlForStub,
request: requestStub,
ghostVersion,
ghostMailer: {
@ -252,7 +248,6 @@ describe('Update Check', function () {
config: {},
i18n: i18nStub,
logging: loggingStub,
urlFor: urlForStub,
request: sinon.stub().resolves({
body: {
notifications: [notification]
@ -323,7 +318,6 @@ describe('Update Check', function () {
},
i18n: i18nStub,
logging: loggingStub,
urlFor: urlForStub,
request: sinon.stub().resolves({
body: [notification]
}),