diff --git a/app/services/service_ping/submit_service.rb b/app/services/service_ping/submit_service.rb index 72d0c02260966a51c0c5f77d2546fef33f0beb48..7243bc411f70e9f80949577e3e7fb82f1b4d803f 100644 --- a/app/services/service_ping/submit_service.rb +++ b/app/services/service_ping/submit_service.rb @@ -16,7 +16,7 @@ def initialize(skip_db_write: false, payload: nil) end def execute - return unless ServicePing::ServicePingSettings.product_intelligence_enabled? + return unless ServicePing::ServicePingSettings.enabled_and_consented? start_time = Time.current diff --git a/ee/lib/ee/service_ping/permit_data_categories.rb b/ee/lib/ee/service_ping/permit_data_categories.rb index e5457d11764d429391391145948486a688d18c4b..9dc8dbf67240a8ffa5104dff320bc3a525142e40 100644 --- a/ee/lib/ee/service_ping/permit_data_categories.rb +++ b/ee/lib/ee/service_ping/permit_data_categories.rb @@ -13,7 +13,7 @@ module PermitDataCategories override :execute def execute return super unless ::License.current.present? - return super unless ::ServicePing::ServicePingSettings.product_intelligence_enabled? + return super unless ::ServicePing::ServicePingSettings.enabled_and_consented? optional_enabled = ::Gitlab::CurrentSettings.usage_ping_enabled? customer_service_enabled = ::License.current.customer_service_enabled? diff --git a/ee/spec/lib/ee/service_ping/permit_data_categories_spec.rb b/ee/spec/lib/ee/service_ping/permit_data_categories_spec.rb index d525284bc735e2fcc51f9e1e593e7b3f6f0a6a9c..654be80ab112a6fbffc84d01ff3619d34aa4eb55 100644 --- a/ee/spec/lib/ee/service_ping/permit_data_categories_spec.rb +++ b/ee/spec/lib/ee/service_ping/permit_data_categories_spec.rb @@ -73,7 +73,7 @@ before do # License.current.usage_ping? == true create_current_license(operational_metrics_enabled: true) - allow(ServicePing::ServicePingSettings).to receive(:product_intelligence_enabled?).and_return(true) + allow(ServicePing::ServicePingSettings).to receive(:enabled_and_consented?).and_return(true) end it 'returns all categories' do diff --git a/ee/spec/lib/ee/service_ping/service_ping_settings_spec.rb b/ee/spec/lib/ee/service_ping/service_ping_settings_spec.rb index 7727ea0060abdd8e7979fcb98d74a15b8397b0ae..856b6603ad52c24fddbeed6eec087ec930c77383 100644 --- a/ee/spec/lib/ee/service_ping/service_ping_settings_spec.rb +++ b/ee/spec/lib/ee/service_ping/service_ping_settings_spec.rb @@ -5,12 +5,12 @@ RSpec.describe ServicePing::ServicePingSettings do using RSpec::Parameterized::TableSyntax - describe '#product_intelligence_enabled?' do + describe '#enabled_and_consented?' do where( :usage_ping_enabled, :customer_service_enabled, :requires_usage_stats_consent, - :expected_product_intelligence_enabled + :expected_enabled_and_consented ) do # Customer service enabled true | true | false | true @@ -39,8 +39,8 @@ create_current_license(operational_metrics_enabled: customer_service_enabled) end - it 'has the correct product_intelligence_enabled?' do - expect(described_class.product_intelligence_enabled?).to eq(expected_product_intelligence_enabled) + it 'has the correct enabled_and_consented?' do + expect(described_class.enabled_and_consented?).to eq(expected_enabled_and_consented) end end end diff --git a/lib/service_ping/service_ping_settings.rb b/lib/service_ping/service_ping_settings.rb index 6964210b1db645a8d87680f3934e661f7feb10e1..8c99f1138c5acd81dcb0b4ad3e04cfa39d23a593 100644 --- a/lib/service_ping/service_ping_settings.rb +++ b/lib/service_ping/service_ping_settings.rb @@ -4,7 +4,7 @@ module ServicePing module ServicePingSettings extend self - def product_intelligence_enabled? + def enabled_and_consented? enabled? && !User.single_user&.requires_usage_stats_consent? end diff --git a/spec/lib/service_ping/service_ping_settings_spec.rb b/spec/lib/service_ping/service_ping_settings_spec.rb index 040a5027274796db5e85626ae6d0ba5f1fe151f7..2e61b35a13198af818064b4c372fa52d629bea42 100644 --- a/spec/lib/service_ping/service_ping_settings_spec.rb +++ b/spec/lib/service_ping/service_ping_settings_spec.rb @@ -5,8 +5,8 @@ RSpec.describe ServicePing::ServicePingSettings do using RSpec::Parameterized::TableSyntax - describe '#product_intelligence_enabled?' do - where(:usage_ping_enabled, :requires_usage_stats_consent, :expected_product_intelligence_enabled) do + describe '#enabled_and_consented?' do + where(:usage_ping_enabled, :requires_usage_stats_consent, :expected_enabled_and_consented) do # Usage ping enabled true | false | true true | true | false @@ -23,8 +23,8 @@ stub_config_setting(usage_ping_enabled: usage_ping_enabled) end - it 'has the correct product_intelligence_enabled?' do - expect(described_class.product_intelligence_enabled?).to eq(expected_product_intelligence_enabled) + it 'has the correct enabled_and_consented?' do + expect(described_class.enabled_and_consented?).to eq(expected_enabled_and_consented) end end end diff --git a/spec/services/service_ping/submit_service_ping_service_spec.rb b/spec/services/service_ping/submit_service_ping_service_spec.rb index 2248febda5c86e322a2702a7b16b50fce5c41e5a..ce0fa6248a134119e45312b7905997997f891826 100644 --- a/spec/services/service_ping/submit_service_ping_service_spec.rb +++ b/spec/services/service_ping/submit_service_ping_service_spec.rb @@ -104,20 +104,20 @@ it_behaves_like 'does not run' end - context 'when product_intelligence_enabled is false' do + context 'when enabled_and_consented is false' do before do - allow(ServicePing::ServicePingSettings).to receive(:product_intelligence_enabled?).and_return(false) + allow(ServicePing::ServicePingSettings).to receive(:enabled_and_consented?).and_return(false) end it_behaves_like 'does not run' end - context 'when product_intelligence_enabled is true' do + context 'when enabled_and_consented is true' do before do stub_usage_data_connections stub_database_flavor_check - allow(ServicePing::ServicePingSettings).to receive(:product_intelligence_enabled?).and_return(true) + allow(ServicePing::ServicePingSettings).to receive(:enabled_and_consented?).and_return(true) end it 'submits a service ping payload without errors', :aggregate_failures do