Commit 6dc75b78 authored by Rajendra Kadam's avatar Rajendra Kadam

Add service ping setting module

parent a117dca9
......@@ -14,20 +14,10 @@ module ServicePing
].to_set.freeze
def execute
return [] unless product_intelligence_enabled?
return [] unless ServicePingSettings.product_intelligence_enabled?
CATEGORIES
end
def product_intelligence_enabled?
pings_enabled? && !User.single_user&.requires_usage_stats_consent?
end
private
def pings_enabled?
::Gitlab::CurrentSettings.usage_ping_enabled?
end
end
end
......
......@@ -42,26 +42,26 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
end
end
describe '#product_intelligence_enabled?' do
where(:usage_ping_enabled, :requires_usage_stats_consent, :expected_product_intelligence_enabled) do
# Usage ping enabled
true | false | true
true | true | false
# describe '#product_intelligence_enabled?' do
# where(:usage_ping_enabled, :requires_usage_stats_consent, :expected_product_intelligence_enabled) do
# # Usage ping enabled
# true | false | true
# true | true | false
# Usage ping disabled
false | false | false
false | true | false
end
# # Usage ping disabled
# false | false | false
# false | true | false
# end
with_them do
before do
allow(User).to receive(:single_user).and_return(double(:user, requires_usage_stats_consent?: requires_usage_stats_consent))
stub_config_setting(usage_ping_enabled: usage_ping_enabled)
end
# with_them do
# before do
# allow(User).to receive(:single_user).and_return(double(:user, requires_usage_stats_consent?: requires_usage_stats_consent))
# stub_config_setting(usage_ping_enabled: usage_ping_enabled)
# end
it 'has the correct product_intelligence_enabled?' do
expect(described_class.new.product_intelligence_enabled?).to eq(expected_product_intelligence_enabled)
end
end
end
# it 'has the correct product_intelligence_enabled?' do
# expect(described_class.new.product_intelligence_enabled?).to eq(expected_product_intelligence_enabled)
# end
# end
# end
end
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