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

Add service ping setting module

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