|
|
|
@ -73,7 +73,7 @@ describe('Settings', () => { |
|
|
|
|
expect(Settings.findOne({ _id: 'my_setting2' }).value).to.be.equal(false); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should respect override via environment', () => { |
|
|
|
|
it('should respect override via environment as int', () => { |
|
|
|
|
process.env.OVERWRITE_SETTING_my_setting = '1'; |
|
|
|
|
|
|
|
|
|
settings.addGroup('group', function() { |
|
|
|
@ -125,6 +125,111 @@ describe('Settings', () => { |
|
|
|
|
expect(Settings.findOne({ _id: 'my_setting' })).to.include(expectedSetting); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should respect override via environment as boolean', () => { |
|
|
|
|
process.env.OVERWRITE_SETTING_my_setting_bool = 'true'; |
|
|
|
|
|
|
|
|
|
settings.addGroup('group', function() { |
|
|
|
|
this.section('section', function() { |
|
|
|
|
this.add('my_setting_bool', false, { |
|
|
|
|
type: 'boolean', |
|
|
|
|
sorter: 0, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const expectedSetting = { |
|
|
|
|
value: true, |
|
|
|
|
processEnvValue: true, |
|
|
|
|
valueSource: 'processEnvValue', |
|
|
|
|
type: 'boolean', |
|
|
|
|
sorter: 0, |
|
|
|
|
group: 'group', |
|
|
|
|
section: 'section', |
|
|
|
|
packageValue: false, |
|
|
|
|
hidden: false, |
|
|
|
|
blocked: false, |
|
|
|
|
secret: false, |
|
|
|
|
i18nLabel: 'my_setting_bool', |
|
|
|
|
i18nDescription: 'my_setting_bool_Description', |
|
|
|
|
autocomplete: true, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
expect(Settings.data.size).to.be.equal(2); |
|
|
|
|
expect(Settings.upsertCalls).to.be.equal(2); |
|
|
|
|
expect(Settings.findOne({ _id: 'my_setting_bool' })).to.include(expectedSetting); |
|
|
|
|
|
|
|
|
|
process.env.OVERWRITE_SETTING_my_setting_bool = 'false'; |
|
|
|
|
|
|
|
|
|
settings.addGroup('group', function() { |
|
|
|
|
this.section('section', function() { |
|
|
|
|
this.add('my_setting_bool', false, { |
|
|
|
|
type: 'boolean', |
|
|
|
|
sorter: 0, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expectedSetting.value = false; |
|
|
|
|
expectedSetting.processEnvValue = false; |
|
|
|
|
|
|
|
|
|
expect(Settings.data.size).to.be.equal(2); |
|
|
|
|
expect(Settings.upsertCalls).to.be.equal(3); |
|
|
|
|
expect(Settings.findOne({ _id: 'my_setting_bool' })).to.include(expectedSetting); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should respect override via environment as string', () => { |
|
|
|
|
process.env.OVERWRITE_SETTING_my_setting_str = 'hey'; |
|
|
|
|
|
|
|
|
|
settings.addGroup('group', function() { |
|
|
|
|
this.section('section', function() { |
|
|
|
|
this.add('my_setting_str', '', { |
|
|
|
|
type: 'string', |
|
|
|
|
sorter: 0, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const expectedSetting = { |
|
|
|
|
value: 'hey', |
|
|
|
|
processEnvValue: 'hey', |
|
|
|
|
valueSource: 'processEnvValue', |
|
|
|
|
type: 'string', |
|
|
|
|
sorter: 0, |
|
|
|
|
group: 'group', |
|
|
|
|
section: 'section', |
|
|
|
|
packageValue: '', |
|
|
|
|
hidden: false, |
|
|
|
|
blocked: false, |
|
|
|
|
secret: false, |
|
|
|
|
i18nLabel: 'my_setting_str', |
|
|
|
|
i18nDescription: 'my_setting_str_Description', |
|
|
|
|
autocomplete: true, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
expect(Settings.data.size).to.be.equal(2); |
|
|
|
|
expect(Settings.upsertCalls).to.be.equal(2); |
|
|
|
|
expect(Settings.findOne({ _id: 'my_setting_str' })).to.include(expectedSetting); |
|
|
|
|
|
|
|
|
|
process.env.OVERWRITE_SETTING_my_setting_str = 'hey ho'; |
|
|
|
|
|
|
|
|
|
settings.addGroup('group', function() { |
|
|
|
|
this.section('section', function() { |
|
|
|
|
this.add('my_setting_str', 'hey', { |
|
|
|
|
type: 'string', |
|
|
|
|
sorter: 0, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
expectedSetting.value = 'hey ho'; |
|
|
|
|
expectedSetting.processEnvValue = 'hey ho'; |
|
|
|
|
expectedSetting.packageValue = 'hey'; |
|
|
|
|
|
|
|
|
|
expect(Settings.data.size).to.be.equal(2); |
|
|
|
|
expect(Settings.upsertCalls).to.be.equal(3); |
|
|
|
|
expect(Settings.findOne({ _id: 'my_setting_str' })).to.include(expectedSetting); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should respect initial value via environment', () => { |
|
|
|
|
process.env.my_setting = '1'; |
|
|
|
|
|
|
|
|
|