diff options
author | Sean McGivern <sean@gitlab.com> | 2017-05-09 22:40:19 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-05-11 11:20:11 +0300 |
commit | 3c546acf78408087b5062be67ae6b05650e0f27e (patch) | |
tree | 0ac538aa9b0786dbac0317693dafa47cf8d01012 /spec | |
parent | 4067dd4f84681dd109fb8e1957b6327b4db20193 (diff) |
Allow disabling usage ping in `gitlab.yml`
Setting `usage_ping_enabled` to false in `gitlab.yml`:
1. Disables the usage ping, regardless of the value stored in the database.
2. Prevents the usage ping from being enabled through the admin panel. It can
only be enabled by either removing the line from `gitlab.yml` and configuring
through the admin panel, or setting it to true in `gitlab.yml`.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/application_setting_spec.rb | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 3c3ae3832de..fa229542f70 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -211,4 +211,66 @@ describe ApplicationSetting, models: true do expect(setting.domain_blacklist).to contain_exactly('example.com', 'test.com', 'foo.bar') end end + + describe 'usage ping settings' do + context 'when the usage ping is disabled in gitlab.yml' do + before do + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(false) + end + + it 'does not allow the usage ping to be configured' do + expect(setting.usage_ping_can_be_configured?).to be_falsey + end + + context 'when the usage ping is disabled in the DB' do + before do + setting.usage_ping_enabled = false + end + + it 'returns false for usage_ping_enabled' do + expect(setting.usage_ping_enabled).to be_falsey + end + end + + context 'when the usage ping is enabled in the DB' do + before do + setting.usage_ping_enabled = true + end + + it 'returns false for usage_ping_enabled' do + expect(setting.usage_ping_enabled).to be_falsey + end + end + end + + context 'when the usage ping is enabled in gitlab.yml' do + before do + allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true) + end + + it 'allows the usage ping to be configured' do + expect(setting.usage_ping_can_be_configured?).to be_truthy + end + + context 'when the usage ping is disabled in the DB' do + before do + setting.usage_ping_enabled = false + end + + it 'returns false for usage_ping_enabled' do + expect(setting.usage_ping_enabled).to be_falsey + end + end + + context 'when the usage ping is enabled in the DB' do + before do + setting.usage_ping_enabled = true + end + + it 'returns true for usage_ping_enabled' do + expect(setting.usage_ping_enabled).to be_truthy + end + end + end + end end |