Commit c4c513b8 authored by alinamihaila's avatar alinamihaila Committed by Thong Kuah

Fix bug where disabling usage ping via gitlab.rb did not work

Add alias method usage_ping_enabled?

Changelog: fixed
parent f1b36261
......@@ -374,6 +374,7 @@ module ApplicationSettingImplementation
def usage_ping_enabled
usage_ping_can_be_configured? && super
end
alias_method :usage_ping_enabled?, :usage_ping_enabled
def allowed_key_types
SUPPORTED_KEY_TYPES.select do |type|
......
......@@ -363,6 +363,85 @@ RSpec.describe ApplicationSetting do
.is_less_than(65536)
end
describe 'usage_ping_enabled setting' do
shared_examples 'usage ping enabled' do
it do
expect(setting.usage_ping_enabled).to eq(true)
expect(setting.usage_ping_enabled?).to eq(true)
end
end
shared_examples 'usage ping disabled' do
it do
expect(setting.usage_ping_enabled).to eq(false)
expect(setting.usage_ping_enabled?).to eq(false)
end
end
context 'when setting is in database' do
context 'with usage_ping_enabled disabled' do
before do
setting.update!(usage_ping_enabled: false)
end
it_behaves_like 'usage ping disabled'
end
context 'with usage_ping_enabled enabled' do
before do
setting.update!(usage_ping_enabled: true)
end
it_behaves_like 'usage ping enabled'
end
end
context 'when setting is in GitLab config' do
context 'with usage_ping_enabled disabled' do
before do
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(false)
end
it_behaves_like 'usage ping disabled'
end
context 'with usage_ping_enabled enabled' do
before do
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true)
end
it_behaves_like 'usage ping enabled'
end
end
context 'when setting in database false and setting in GitLab config true' do
before do
setting.update!(usage_ping_enabled: false)
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true)
end
it_behaves_like 'usage ping disabled'
end
context 'when setting database true and setting in GitLab config false' do
before do
setting.update!(usage_ping_enabled: true)
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(false)
end
it_behaves_like 'usage ping disabled'
end
context 'when setting database true and setting in GitLab config true' do
before do
setting.update!(usage_ping_enabled: true)
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true)
end
it_behaves_like 'usage ping enabled'
end
end
context 'key restrictions' do
it 'supports all key types' do
expect(described_class::SUPPORTED_KEY_TYPES).to contain_exactly(:rsa, :dsa, :ecdsa, :ed25519)
......
......@@ -90,6 +90,14 @@ RSpec.describe SubmitUsagePingService do
it_behaves_like 'does not run'
end
context 'when usage ping is disabled from GitLab config file' do
before do
stub_config_setting(usage_ping_enabled: false)
end
it_behaves_like 'does not run'
end
context 'when usage ping is enabled' do
before do
stub_usage_data_connections
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment