mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Restored labs' getAll function
refs https://github.com/TryGhost/Team/issues/757
refs 37ef40b46e/core/server/services/labs.js
- As more labs flags have been added to allowlist the `getAll` method should be returning members+all allowlisted flags
- The changeset restored the state of the method to the one reffed in the commit
This commit is contained in:
parent
5f45f870a0
commit
7a21522804
2 changed files with 29 additions and 3 deletions
|
@ -14,9 +14,13 @@ const WRITABLE_KEYS_ALLOWLIST = [
|
|||
|
||||
module.exports.WRITABLE_KEYS_ALLOWLIST = WRITABLE_KEYS_ALLOWLIST;
|
||||
|
||||
module.exports.getAll = () => ({
|
||||
members: settingsCache.get('members_signup_access') !== 'none'
|
||||
});
|
||||
module.exports.getAll = () => {
|
||||
const labs = _.cloneDeep(settingsCache.get('labs')) || {};
|
||||
|
||||
labs.members = settingsCache.get('members_signup_access') !== 'none';
|
||||
|
||||
return labs;
|
||||
};
|
||||
|
||||
module.exports.isSet = function isSet(flag) {
|
||||
const labsConfig = module.exports.getAll();
|
||||
|
|
|
@ -9,6 +9,12 @@ describe('Labs Service', function () {
|
|||
sinon.restore();
|
||||
});
|
||||
|
||||
it('can getAll, even if empty with enabled members', function () {
|
||||
labs.getAll().should.eql({
|
||||
members: true
|
||||
});
|
||||
});
|
||||
|
||||
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');
|
||||
|
@ -20,6 +26,22 @@ describe('Labs Service', function () {
|
|||
labs.isSet('members').should.be.true;
|
||||
});
|
||||
|
||||
it('returns other allowlisted flags along with members', function () {
|
||||
sinon.stub(settingsCache, 'get');
|
||||
settingsCache.get.withArgs('members_signup_access').returns('all');
|
||||
settingsCache.get.withArgs('labs').returns({
|
||||
activitypub: false
|
||||
});
|
||||
|
||||
labs.getAll().should.eql({
|
||||
members: true,
|
||||
activitypub: false
|
||||
});
|
||||
|
||||
labs.isSet('members').should.be.true;
|
||||
labs.isSet('activitypub').should.be.false;
|
||||
});
|
||||
|
||||
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');
|
||||
|
|
Loading…
Add table
Reference in a new issue