0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Set @labs.members to false when members_signup_acess == 'none'

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

- setting `members_signup_access` to `'none'` effectively disables all built-in members functions on the front-end so setting `@labs.members` to `false` allows themes to react accordingly
- `@labs.members` keeps backwards compatibility with pre-4.0 versions where themes were using it to toggle member-related functionality
This commit is contained in:
Kevin Ansfield 2021-04-19 18:28:51 +01:00
parent 4a8352c418
commit 5c41c67ffc
2 changed files with 18 additions and 2 deletions

View file

@ -4,9 +4,10 @@ const SafeString = require('../../frontend/services/themes/engine').SafeString;
const errors = require('@tryghost/errors');
const {i18n} = require('../lib/common');
const logging = require('../../shared/logging');
const settingsCache = require('../services/settings/cache');
module.exports.getAll = () => ({
members: true
members: settingsCache.get('members_signup_access') !== 'none'
});
module.exports.isSet = function isSet(flag) {

View file

@ -2,13 +2,17 @@ const should = require('should');
const sinon = require('sinon');
const labs = require('../../../core/server/services/labs');
const settingsCache = require('../../../core/server/services/settings/cache');
describe('Labs Service', function () {
afterEach(function () {
sinon.restore();
});
it('always returns members true flag', function () {
it('members flag is true when members_signup_access setting is "all"', function () {
sinon.stub(settingsCache, 'get');
settingsCache.get.withArgs('members_signup_access').returns('all');
labs.getAll().should.eql({
members: true
});
@ -16,6 +20,17 @@ describe('Labs Service', function () {
labs.isSet('members').should.be.true;
});
it('members flag is false when members_signup_access setting is "none"', function () {
sinon.stub(settingsCache, 'get');
settingsCache.get.withArgs('members_signup_access').returns('none');
labs.getAll().should.eql({
members: false
});
labs.isSet('members').should.be.false;
});
it('isSet returns false for undefined', function () {
labs.isSet('bar').should.be.false;
});