0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-15 03:01:37 -05:00

🐛 Fixed author helper not returning the correct url (#9102)

closes #9101

With 506a0c3e9e we don't expose the `status` field for author context anymore, which is used to determine the correct URL for the `{{url}}` helper in https://github.com/TryGhost/Ghost/blob/master/core/server/data/schema/checks.js#L13

This fix uses the field `profile_image` instead and adds a missing test for author context to the `{{url}}` helper test.
This commit is contained in:
Aileen Nowak 2017-10-05 18:50:55 +07:00 committed by Katharina Irrgang
parent 30e790bf12
commit 19167c1af2
4 changed files with 17 additions and 4 deletions

View file

@ -10,7 +10,7 @@ function isTag(jsonData) {
function isUser(jsonData) {
return jsonData.hasOwnProperty('bio') && jsonData.hasOwnProperty('website') &&
jsonData.hasOwnProperty('status') && jsonData.hasOwnProperty('location');
jsonData.hasOwnProperty('profile_image') && jsonData.hasOwnProperty('location');
}
function isNav(jsonData) {

View file

@ -49,7 +49,7 @@ describe('getCanonicalUrl', function () {
name: 'Test User',
bio: 'This is all about testing',
website: 'http://my-testing-site.com',
status: 'testing',
profile_image: null,
location: 'Wounderland',
slug: 'test-user',
secure: true

View file

@ -77,7 +77,7 @@ describe('getUrl', function () {
name: 'Author Name',
bio: 'I am fun bio!',
website: 'http://myoksite.com',
status: 'active',
profile_image: null,
location: 'London',
slug: 'author-name'
});
@ -89,7 +89,7 @@ describe('getUrl', function () {
name: 'Author Name',
bio: 'I am fun bio!',
website: 'http://myoksite.com',
status: 'active',
profile_image: null,
location: 'London',
slug: 'author-name',
secure: true

View file

@ -94,6 +94,19 @@ describe('{{url}} helper', function () {
rendered.string.should.equal('/tag/the-tag/');
});
it('should return the slug with a prefixed /author/ if the context is author', function () {
rendered = helpers.url.call({
bio: null,
website: null,
profile_image: null,
location: null,
slug: 'some-author'
});
should.exist(rendered);
rendered.string.should.equal('/author/some-author/');
});
it('should return / if not a post or tag', function () {
rendered = helpers.url.call({mobiledoc: markdownToMobiledoc('ff'), title: 'title', slug: 'slug'});
should.exist(rendered);