chore: revert GlobalConfig changes (#3702)

Priority to GlobalConfig changes are reverted and for the time being, env vars will take precedence if set.

Fixes #3699
This commit is contained in:
Vishnu Narayanan
2022-01-12 08:50:23 +05:30
committed by GitHub
parent f44be0b1e6
commit acba07cf6e
4 changed files with 59 additions and 59 deletions

View File

@@ -10,35 +10,34 @@ describe GlobalConfigService do
GlobalConfig.clear_cache
end
it 'set default value if not found on db nor env var' do
value = GlobalConfig.get('ENABLE_ACCOUNT_SIGNUP')
expect(value['ENABLE_ACCOUNT_SIGNUP']).to eq nil
# it 'set default value if not found on db nor env var' do
# value = GlobalConfig.get('ENABLE_ACCOUNT_SIGNUP')
# expect(value['ENABLE_ACCOUNT_SIGNUP']).to eq nil
described_class.load('ENABLE_ACCOUNT_SIGNUP', 'true')
# described_class.load('ENABLE_ACCOUNT_SIGNUP', 'true')
value = GlobalConfig.get('ENABLE_ACCOUNT_SIGNUP')
expect(value['ENABLE_ACCOUNT_SIGNUP']).to eq 'true'
expect(InstallationConfig.find_by(name: 'ENABLE_ACCOUNT_SIGNUP')&.value).to eq 'true'
end
# value = GlobalConfig.get('ENABLE_ACCOUNT_SIGNUP')
# expect(value['ENABLE_ACCOUNT_SIGNUP']).to eq 'true'
# expect(InstallationConfig.find_by(name: 'ENABLE_ACCOUNT_SIGNUP')&.value).to eq 'true'
# end
it 'get value from env variable if not found on DB' do
it 'get value from env variable even if present on DB' do
with_modified_env ENABLE_ACCOUNT_SIGNUP: 'false' do
expect(InstallationConfig.find_by(name: 'ENABLE_ACCOUNT_SIGNUP')&.value).to eq nil
described_class.load('ENABLE_ACCOUNT_SIGNUP', 'true')
value = GlobalConfig.get('ENABLE_ACCOUNT_SIGNUP')
expect(value['ENABLE_ACCOUNT_SIGNUP']).to eq 'false'
value = described_class.load('ENABLE_ACCOUNT_SIGNUP', 'true')
expect(value).to eq 'false'
end
end
it 'get value from DB if found' do
# Set a value in db first and make sure this value
# is not respected even when load() method is called with
# another value.
InstallationConfig.where(name: 'ENABLE_ACCOUNT_SIGNUP').first_or_create(value: 'true')
described_class.load('ENABLE_ACCOUNT_SIGNUP', 'false')
value = GlobalConfig.get('ENABLE_ACCOUNT_SIGNUP')
expect(value['ENABLE_ACCOUNT_SIGNUP']).to eq 'true'
end
# it 'get value from DB if found' do
# # Set a value in db first and make sure this value
# # is not respected even when load() method is called with
# # another value.
# InstallationConfig.where(name: 'ENABLE_ACCOUNT_SIGNUP').first_or_create(value: 'true')
# described_class.load('ENABLE_ACCOUNT_SIGNUP', 'false')
# value = GlobalConfig.get('ENABLE_ACCOUNT_SIGNUP')
# expect(value['ENABLE_ACCOUNT_SIGNUP']).to eq 'true'
# end
end
end
end