Moved image utils to lib/image

refs #9178

- i am not super happy about `const imageLib = require('../lib/image')`
- i don't really like the name `imageLib`
- but i had no better idea 😃
- if we use the same name in the whole project, it's very easy to rename the folder or the variable
This commit is contained in:
kirrg001 2017-12-14 20:46:53 +01:00
parent 740b247a80
commit fc5b4dd934
20 changed files with 127 additions and 102 deletions

View File

@ -2,7 +2,7 @@
const crypto = require('crypto'),
config = require('../../config'),
blogIconUtils = require('../../utils/blog-icon'),
imageLib = require('../../lib/image'),
urlService = require('../../services/url'),
packageInfo = require('../../../../package.json');
@ -11,7 +11,7 @@ const crypto = require('crypto'),
* @return {string}
*/
function getFaviconUrl() {
return blogIconUtils.getIconUrl();
return imageLib.blogIcon.getIconUrl();
}
function getAssetUrl(path, hasMinFile) {

View File

@ -1,6 +1,6 @@
var urlService = require('../../services/url'),
settingsCache = require('../../services/settings/cache'),
blogIconUtils = require('../../utils/blog-icon');
imageLib = require('../../lib/image');
function getBlogLogo() {
var logo = {};
@ -11,7 +11,7 @@ function getBlogLogo() {
// CASE: no publication logo is updated. We can try to use either an uploaded publication icon
// or use the default one to make
// Google happy with it. See https://github.com/TryGhost/Ghost/issues/7558
logo.url = blogIconUtils.getIconUrl(true);
logo.url = imageLib.blogIcon.getIconUrl(true);
}
return logo;

View File

@ -1,6 +1,6 @@
var getCachedImageSizeFromUrl = require('../../utils/cached-image-size-from-url'),
Promise = require('bluebird'),
_ = require('lodash');
var Promise = require('bluebird'),
_ = require('lodash'),
imageLib = require('../../lib/image');
/**
* Get Image dimensions
@ -11,10 +11,10 @@ var getCachedImageSizeFromUrl = require('../../utils/cached-image-size-from-url'
*/
function getImageDimensions(metaData) {
var fetch = {
coverImage: getCachedImageSizeFromUrl(metaData.coverImage.url),
authorImage: getCachedImageSizeFromUrl(metaData.authorImage.url),
ogImage: getCachedImageSizeFromUrl(metaData.ogImage.url),
logo: getCachedImageSizeFromUrl(metaData.blog.logo.url)
coverImage: imageLib.imageSizeCache(metaData.coverImage.url),
authorImage: imageLib.imageSizeCache(metaData.authorImage.url),
ogImage: imageLib.imageSizeCache(metaData.ogImage.url),
logo: imageLib.imageSizeCache(metaData.blog.logo.url)
};
return Promise

View File

@ -63,7 +63,7 @@ module.exports = {
// Various utils, needs cleaning up / simplifying
socialUrls: require('../utils/social-urls'),
blogIcon: require('../utils/blog-icon'),
blogIcon: require('../lib/image/blog-icon'),
url: require('../services/url').utils,
localUtils: require('./utils')
};

View File

@ -2,11 +2,11 @@ var sizeOf = require('image-size'),
Promise = require('bluebird'),
_ = require('lodash'),
path = require('path'),
common = require('../lib/common'),
settingsCache = require('../services/settings/cache'),
config = require('../config'),
urlService = require('../services/url'),
storageUtils = require('../adapters/storage/utils'),
config = require('../../config'),
common = require('../common'),
settingsCache = require('../../services/settings/cache'),
urlService = require('../../services/url'),
storageUtils = require('../../adapters/storage/utils'),
getIconDimensions,
isIcoImageType,
getIconType,

View File

@ -1,7 +1,7 @@
var debug = require('ghost-ignition').debug('utils:image-size-cache'),
imageSize = require('./image-size'),
common = require('../lib/common'),
imageSizeCache = {};
common = require('../common'),
cache = {};
/**
* Get cached image size from URL
@ -17,32 +17,32 @@ function getCachedImageSizeFromUrl(url) {
}
// image size is not in cache
if (!imageSizeCache[url]) {
if (!cache[url]) {
return imageSize.getImageSizeFromUrl(url).then(function (res) {
imageSizeCache[url] = res;
cache[url] = res;
debug('Cached image:', url);
return imageSizeCache[url];
return cache[url];
}).catch(common.errors.NotFoundError, function () {
debug('Cached image (not found):', url);
// in case of error we just attach the url
imageSizeCache[url] = url;
cache[url] = url;
return imageSizeCache[url];
return cache[url];
}).catch(function (err) {
debug('Cached image (error):', url);
common.logging.error(err);
// in case of error we just attach the url
imageSizeCache[url] = url;
cache[url] = url;
return imageSizeCache[url];
return cache[url];
});
}
debug('Read image from cache:', url);
// returns image size from cache
return imageSizeCache[url];
return cache[url];
}
module.exports = getCachedImageSizeFromUrl;

View File

@ -1,7 +1,7 @@
var Promise = require('bluebird'),
crypto = require('crypto'),
config = require('../config'),
request = require('../lib/request');
config = require('../../config'),
request = require('../request');
module.exports.lookup = function lookup(userData, timeout) {
var gravatarUrl = '//www.gravatar.com/avatar/' +

View File

@ -2,13 +2,13 @@ var debug = require('ghost-ignition').debug('utils:image-size'),
sizeOf = require('image-size'),
url = require('url'),
Promise = require('bluebird'),
request = require('../lib/request'),
urlService = require('../services/url'),
common = require('../lib/common'),
config = require('../config'),
storage = require('../adapters/storage'),
_ = require('lodash'),
storageUtils = require('../adapters/storage/utils'),
request = require('../request'),
urlService = require('../../services/url'),
common = require('../common'),
config = require('../../config'),
storage = require('../../adapters/storage'),
storageUtils = require('../../adapters/storage/utils'),
getImageSizeFromUrl,
getImageSizeFromFilePath;

View File

@ -0,0 +1,19 @@
'use strict';
module.exports = {
get blogIcon() {
return require('./blog-icon');
},
get imageSize() {
return require('./image-size');
},
get gravatar() {
return require('./gravatar');
},
get imageSizeCache() {
return require('./cached-image-size-from-url');
}
};

View File

@ -7,9 +7,9 @@ var _ = require('lodash'),
baseUtils = require('./base/utils'),
common = require('../lib/common'),
security = require('../lib/security'),
gravatar = require('../utils/gravatar'),
validation = require('../data/validation'),
imageLib = require('../lib/image'),
pipeline = require('../lib/promise/pipeline'),
validation = require('../data/validation'),
bcryptGenSalt = Promise.promisify(bcrypt.genSalt),
bcryptHash = Promise.promisify(bcrypt.hash),
@ -107,7 +107,7 @@ User = ghostBookshelf.Model.extend({
// If the user's email is set & has changed & we are not importing
if (self.hasChanged('email') && self.get('email') && !options.importing) {
tasks.gravatar = (function lookUpGravatar() {
return gravatar.lookup({
return imageLib.gravatar.lookup({
email: self.get('email')
}).then(function (response) {
if (response && response.image) {

View File

@ -1,7 +1,7 @@
var common = require('../lib/common'),
request = require('../lib/request'),
imageLib = require('../lib/image'),
urlService = require('../services/url'),
blogIconUtils = require('../utils/blog-icon'),
settingsCache = require('./settings/cache'),
schema = require('../data/schema').checks,
defaultPostSlugs = [
@ -50,7 +50,7 @@ function ping(post) {
slackData = {
text: message,
unfurl_links: true,
icon_url: blogIconUtils.getIconUrl(true),
icon_url: imageLib.blogIcon.getIconUrl(true),
username: 'Ghost'
};

View File

@ -1,11 +1,11 @@
var fs = require('fs-extra'),
path = require('path'),
crypto = require('crypto'),
config = require('../../config'),
imageLib = require('../../lib/image'),
storage = require('../../adapters/storage'),
urlService = require('../../services/url'),
config = require('../../config'),
settingsCache = require('../../services/settings/cache'),
blogIconUtils = require('../../utils/blog-icon'),
buildContentResponse,
content;
@ -37,7 +37,7 @@ function serveFavicon() {
// we are using an express route to skip /content/images and the result is a image path
// based on config.getContentPath('images') + req.path
// in this case we don't use path rewrite, that's why we have to make it manually
filePath = blogIconUtils.getIconPath();
filePath = imageLib.blogIcon.getIconPath();
var originalExtension = path.extname(filePath).toLowerCase(),
requestedExtension = path.extname(req.path).toLowerCase();
@ -52,7 +52,7 @@ function serveFavicon() {
storage.getStorage()
.read({path: filePath})
.then(function readFile(buf) {
iconType = blogIconUtils.getIconType();
iconType = imageLib.blogIcon.getIconType();
content = buildContentResponse(iconType, buf);
res.writeHead(200, content.headers);

View File

@ -1,6 +1,6 @@
var config = require('../../../config'),
common = require('../../../lib/common'),
blogIconUtils = require('../../../utils/blog-icon'),
imageLib = require('../../../lib/image'),
validIconFileSize;
validIconFileSize = function validIconFileSize(size) {
@ -14,27 +14,35 @@ module.exports = function blogIcon() {
// CASE: file should not be larger than 100kb
if (!validIconFileSize(req.file.size)) {
return next(new common.errors.ValidationError({message: common.i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})}));
return next(new common.errors.ValidationError({
message: common.i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
}));
}
return blogIconUtils.getIconDimensions(req.file.path).then(function (response) {
return imageLib.blogIcon.getIconDimensions(req.file.path).then(function (response) {
// save the image dimensions in new property for file
req.file.dimensions = response;
// CASE: file needs to be a square
if (req.file.dimensions.width !== req.file.dimensions.height) {
return next(new common.errors.ValidationError({message: common.i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})}));
return next(new common.errors.ValidationError({
message: common.i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
}));
}
// CASE: icon needs to be bigger than or equal to 60px
// .ico files can contain multiple sizes, we need at least a minimum of 60px (16px is ok, as long as 60px are present as well)
if (req.file.dimensions.width < 60) {
return next(new common.errors.ValidationError({message: common.i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})}));
return next(new common.errors.ValidationError({
message: common.i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
}));
}
// CASE: icon needs to be smaller than or equal to 1000px
if (req.file.dimensions.width > 1000) {
return next(new common.errors.ValidationError({message: common.i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})}));
return next(new common.errors.ValidationError({
message: common.i18n.t('errors.api.icons.invalidFile', {extensions: iconExtensions})
}));
}
next();

View File

@ -6,7 +6,7 @@ var should = require('should'),
// Stuff we are testing
common = require('../../../server/lib/common'),
gravatar = require('../../../server/utils/gravatar'),
imageLib = require('../../../server/lib/image'),
UserModel = require('../../../server/models/user').User,
RoleModel = require('../../../server/models/role').Role,
context = testUtils.context.admin,
@ -89,7 +89,7 @@ describe('User Model', function run() {
it('can find gravatar', function (done) {
var userData = testUtils.DataGenerator.forModel.users[4];
sandbox.stub(gravatar, 'lookup').callsFake(function (userData) {
sandbox.stub(imageLib.gravatar, 'lookup').callsFake(function (userData) {
userData.image = 'http://www.gravatar.com/avatar/2fab21a4c4ed88e76add10650c73bae1?d=404';
return Promise.resolve(userData);
});
@ -106,7 +106,7 @@ describe('User Model', function run() {
it('can handle no gravatar', function (done) {
var userData = testUtils.DataGenerator.forModel.users[0];
sandbox.stub(gravatar, 'lookup').callsFake(function (userData) {
sandbox.stub(imageLib.gravatar, 'lookup').callsFake(function (userData) {
return Promise.resolve(userData);
});

View File

@ -2,7 +2,6 @@ var should = require('should'),
sinon = require('sinon'),
rewire = require('rewire'),
getImageDimensions = rewire('../../../../server/data/meta/image-dimensions'),
getCachedImageSizeFromUrl = rewire('../../../../server/utils/cached-image-size-from-url'),
sandbox = sinon.sandbox.create();
describe('getImageDimensions', function () {
@ -14,7 +13,6 @@ describe('getImageDimensions', function () {
afterEach(function () {
sandbox.restore();
getCachedImageSizeFromUrl.__set__('imageSizeCache', {});
});
it('should return dimension for images', function (done) {
@ -41,7 +39,7 @@ describe('getImageDimensions', function () {
type: 'jpg'
});
getImageDimensions.__set__('getCachedImageSizeFromUrl', sizeOfStub);
getImageDimensions.__set__('imageLib', {imageSizeCache: sizeOfStub});
getImageDimensions(metaData).then(function (result) {
should.exist(result);
@ -92,7 +90,7 @@ describe('getImageDimensions', function () {
sizeOfStub.returns({});
getImageDimensions.__set__('getCachedImageSizeFromUrl', sizeOfStub);
getImageDimensions.__set__('imageLib', {imageSizeCache: sizeOfStub});
getImageDimensions(metaData).then(function (result) {
should.exist(result);
@ -136,7 +134,7 @@ describe('getImageDimensions', function () {
type: 'jpg'
});
getImageDimensions.__set__('getCachedImageSizeFromUrl', sizeOfStub);
getImageDimensions.__set__('imageLib', {imageSizeCache: sizeOfStub});
getImageDimensions(metaData).then(function (result) {
should.exist(result);
@ -188,7 +186,7 @@ describe('getImageDimensions', function () {
type: 'jpg'
});
getImageDimensions.__set__('getCachedImageSizeFromUrl', sizeOfStub);
getImageDimensions.__set__('imageLib', {imageSizeCache: sizeOfStub});
getImageDimensions(metaData).then(function (result) {
should.exist(result);

View File

@ -6,7 +6,7 @@ var should = require('should'), // jshint ignore:line
testUtils = require('../../utils'),
configUtils = require('../../utils/configUtils'),
helpers = require('../../../server/helpers'),
imageSize = require('../../../server/utils/image-size'),
imageLib = require('../../../server/lib/image'),
proxy = require('../../../server/helpers/proxy'),
settingsCache = proxy.settingsCache,
api = proxy.api,
@ -26,7 +26,7 @@ describe('{{ghost_head}} helper', function () {
* The image path is e.g. localhost:port/favicon.ico, but no server is running.
* If we don't mock the image size utility, we run into lot's of timeouts.
*/
sandbox.stub(imageSize, 'getImageSizeFromUrl').returns(Promise.resolve());
sandbox.stub(imageLib.imageSize, 'getImageSizeFromUrl').resolves();
sandbox.stub(api.clients, 'read').returns(Promise.resolve({
clients: [

View File

@ -2,19 +2,19 @@
var should = require('should'),
sinon = require('sinon'),
_ = require('lodash'),
settingsCache = require('../../../server/services/settings/cache'),
configUtils = require('../../utils/configUtils'),
testUtils = require('../../utils'),
config = configUtils.config,
path = require('path'),
rewire = require('rewire'),
settingsCache = require('../../../../server/services/settings/cache'),
configUtils = require('../../../utils/configUtils'),
testUtils = require('../../../utils'),
config = configUtils.config,
// stuff we are testing
blogIcon = rewire('../../../server/utils/blog-icon'),
blogIcon = rewire('../../../../server/lib/image/blog-icon'),
sandbox = sinon.sandbox.create();
describe('Blog Icon', function () {
describe('lib/image: blog icon', function () {
before(function () {
configUtils.restore();
});
@ -22,7 +22,7 @@ describe('Blog Icon', function () {
afterEach(function () {
configUtils.restore();
sandbox.restore();
rewire('../../../server/utils/blog-icon');
rewire('../../../../server/lib/image/blog-icon');
});
describe('getIconUrl', function () {
@ -92,7 +92,7 @@ describe('Blog Icon', function () {
});
it('default ico blog icon', function () {
blogIcon.getIconPath().should.eql(path.join(__dirname, '../../../server/public/favicon.ico'));
blogIcon.getIconPath().should.eql(path.join(__dirname, '../../../../server/public/favicon.ico'));
});
describe('with subdirectory', function () {
@ -112,7 +112,7 @@ describe('Blog Icon', function () {
it('default ico blog icon', function () {
configUtils.set({url: 'http://my-ghost-blog.com/blog'});
blogIcon.getIconPath().should.eql(path.join(__dirname, '../../../server/public/favicon.ico'));
blogIcon.getIconPath().should.eql(path.join(__dirname, '../../../../server/public/favicon.ico'));
});
});
});
@ -139,7 +139,7 @@ describe('Blog Icon', function () {
describe('getIconDimensions', function () {
it('[success] returns .ico dimensions', function (done) {
blogIcon.getIconDimensions(path.join(__dirname, '../../utils/fixtures/images/favicon.ico'))
blogIcon.getIconDimensions(path.join(__dirname, '../../../utils/fixtures/images/favicon.ico'))
.then(function (result) {
should.exist(result);
result.should.eql({
@ -151,7 +151,7 @@ describe('Blog Icon', function () {
});
it('[success] returns .png dimensions', function (done) {
blogIcon.getIconDimensions(path.join(__dirname, '../../utils/fixtures/images/favicon.png'))
blogIcon.getIconDimensions(path.join(__dirname, '../../../utils/fixtures/images/favicon.png'))
.then(function (result) {
should.exist(result);
result.should.eql({
@ -163,7 +163,7 @@ describe('Blog Icon', function () {
});
it('[success] returns .ico dimensions for icon with multiple sizes', function (done) {
blogIcon.getIconDimensions(path.join(__dirname, '../../utils/fixtures/images/favicon_multi_sizes.ico'))
blogIcon.getIconDimensions(path.join(__dirname, '../../../utils/fixtures/images/favicon_multi_sizes.ico'))
.then(function (result) {
should.exist(result);
result.should.eql({
@ -181,7 +181,7 @@ describe('Blog Icon', function () {
blogIcon.__set__('sizeOf', sizeOfStub);
blogIcon.getIconDimensions(path.join(__dirname, '../../utils/fixtures/images/favicon_multi_sizes.ico'))
blogIcon.getIconDimensions(path.join(__dirname, '../../../utils/fixtures/images/favicon_multi_sizes.ico'))
.catch(function (error) {
should.exist(error);
error.message.should.eql('Could not fetch icon dimensions.');

View File

@ -4,11 +4,11 @@ var should = require('should'),
rewire = require('rewire'),
// Stuff we are testing
getCachedImageSizeFromUrl = rewire('../../../server/utils/cached-image-size-from-url'),
getCachedImageSizeFromUrl = rewire('../../../../server/lib/image/cached-image-size-from-url'),
sandbox = sinon.sandbox.create();
describe('getCachedImageSizeFromUrl', function () {
describe('lib/image: image size cache', function () {
var sizeOfStub,
cachedImagedSize;
@ -18,7 +18,7 @@ describe('getCachedImageSizeFromUrl', function () {
afterEach(function () {
sandbox.restore();
getCachedImageSizeFromUrl.__set__('imageSizeCache', {});
getCachedImageSizeFromUrl.__set__('cache', {});
});
it('should read from cache, if dimensions for image are fetched already', function (done) {
@ -39,7 +39,7 @@ describe('getCachedImageSizeFromUrl', function () {
cachedImagedSizeResult = Promise.resolve(getCachedImageSizeFromUrl(url));
cachedImagedSizeResult.then(function () {
// first call to get result from `getImageSizeFromUrl`
cachedImagedSize = getCachedImageSizeFromUrl.__get__('imageSizeCache');
cachedImagedSize = getCachedImageSizeFromUrl.__get__('cache');
should.exist(cachedImagedSize);
cachedImagedSize.should.have.property(url);
should.exist(cachedImagedSize[url].width);
@ -50,7 +50,7 @@ describe('getCachedImageSizeFromUrl', function () {
// second call to check if values get returned from cache
cachedImagedSizeResult = Promise.resolve(getCachedImageSizeFromUrl(url));
cachedImagedSizeResult.then(function () {
cachedImagedSize = getCachedImageSizeFromUrl.__get__('imageSizeCache');
cachedImagedSize = getCachedImageSizeFromUrl.__get__('cache');
imageSizeSpy.calledOnce.should.be.true();
imageSizeSpy.calledTwice.should.be.false();
should.exist(cachedImagedSize);
@ -75,13 +75,13 @@ describe('getCachedImageSizeFromUrl', function () {
cachedImagedSizeResult = Promise.resolve(getCachedImageSizeFromUrl(url));
cachedImagedSizeResult.then(function () {
cachedImagedSize = getCachedImageSizeFromUrl.__get__('imageSizeCache');
should.exist(cachedImagedSize);
cachedImagedSize.should.have.property(url);
should.not.exist(cachedImagedSize[url].width);
should.not.exist(cachedImagedSize[url].height);
done();
}).catch(done);
cachedImagedSize = getCachedImageSizeFromUrl.__get__('cache');
should.exist(cachedImagedSize);
cachedImagedSize.should.have.property(url);
should.not.exist(cachedImagedSize[url].width);
should.not.exist(cachedImagedSize[url].height);
done();
}).catch(done);
});
it('should return null if url is undefined', function (done) {

View File

@ -1,9 +1,9 @@
var should = require('should'), // jshint ignore:line
nock = require('nock'),
configUtils = require('../../utils/configUtils'),
gravatar = require('../../../server/utils/gravatar');
configUtils = require('../../../utils/configUtils'),
gravatar = require('../../../../server/lib/image/gravatar');
describe('Utils: gravatar-lookup', function () {
describe('lib/image: gravatar', function () {
beforeEach(function () {
configUtils.set('privacy:useGravatar', true);
});

View File

@ -3,17 +3,17 @@ var should = require('should'),
rewire = require('rewire'),
nock = require('nock'),
path = require('path'),
configUtils = require('../../utils/configUtils'),
urlService = require('../../../server/services/url'),
common = require('../../../server/lib/common'),
storage = require('../../../server/adapters/storage'),
configUtils = require('../../../utils/configUtils'),
urlService = require('../../../../server/services/url'),
common = require('../../../../server/lib/common'),
storage = require('../../../../server/adapters/storage'),
// Stuff we are testing
imageSize = rewire('../../../server/utils/image-size'),
imageSize = rewire('../../../../server/lib/image/image-size'),
sandbox = sinon.sandbox.create();
describe('Image Size', function () {
describe('lib/image: image size', function () {
var sizeOfStub,
result,
requestMock,
@ -27,7 +27,7 @@ describe('Image Size', function () {
afterEach(function () {
sandbox.restore();
configUtils.restore();
imageSize = rewire('../../../server/utils/image-size');
imageSize = rewire('../../../../server/lib/image/image-size');
storage.getStorage().storagePath = originalStoragePath;
});
@ -263,7 +263,7 @@ describe('Image Size', function () {
width: 100
};
storage.getStorage().storagePath = path.join(__dirname, '../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
urlForStub = sandbox.stub(urlService.utils, 'urlFor');
urlForStub.withArgs('image').returns('http://myblog.com/content/images/favicon.png');
urlForStub.withArgs('home').returns('http://myblog.com/');
@ -370,7 +370,7 @@ describe('Image Size', function () {
width: 800
};
storage.getStorage().storagePath = path.join(__dirname, '../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
urlForStub = sandbox.stub(urlService.utils, 'urlFor');
urlForStub.withArgs('image').returns('http://myblog.com/content/images/ghost-logo.png');
urlForStub.withArgs('home').returns('http://myblog.com/');
@ -400,7 +400,7 @@ describe('Image Size', function () {
width: 1010
};
storage.getStorage().storagePath = path.join(__dirname, '../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
urlForStub = sandbox.stub(urlService.utils, 'urlFor');
urlForStub.withArgs('image').returns('http://myblog.com/blog/content/images/favicon_too_large.png');
urlForStub.withArgs('home').returns('http://myblog.com/');
@ -430,7 +430,7 @@ describe('Image Size', function () {
width: 64
};
storage.getStorage().storagePath = path.join(__dirname, '../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
urlForStub = sandbox.stub(urlService.utils, 'urlFor');
urlForStub.withArgs('image').returns('http://myblog.com/content/images/favicon_multi_sizes.ico');
urlForStub.withArgs('home').returns('http://myblog.com/');
@ -454,7 +454,7 @@ describe('Image Size', function () {
urlForStub,
urlGetSubdirStub;
storage.getStorage().storagePath = path.join(__dirname, '../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
urlForStub = sandbox.stub(urlService.utils, 'urlFor');
urlForStub.withArgs('image').returns('http://myblog.com/content/images/not-existing-image.png');
urlForStub.withArgs('home').returns('http://myblog.com/');
@ -478,7 +478,7 @@ describe('Image Size', function () {
sizeOfStub.throws({error: 'image-size could not find dimensions'});
imageSize.__set__('sizeOf', sizeOfStub);
storage.getStorage().storagePath = path.join(__dirname, '../../../test/utils/fixtures/images/');
storage.getStorage().storagePath = path.join(__dirname, '../../../../test/utils/fixtures/images/');
urlForStub = sandbox.stub(urlService.utils, 'urlFor');
urlForStub.withArgs('image').returns('http://myblog.com/content/images/ghost-logo.pngx');
urlForStub.withArgs('home').returns('http://myblog.com/');