Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-19 12:08:42 +0300
commitb76ae638462ab0f673e5915986070518dd3f9ad3 (patch)
treebdab0533383b52873be0ec0eb4d3c66598ff8b91 /spec/services/service_ping
parent434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff)
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'spec/services/service_ping')
-rw-r--r--spec/services/service_ping/permit_data_categories_service_spec.rb27
-rw-r--r--spec/services/service_ping/service_ping_settings_spec.rb46
-rw-r--r--spec/services/service_ping/submit_service_ping_service_spec.rb8
3 files changed, 49 insertions, 32 deletions
diff --git a/spec/services/service_ping/permit_data_categories_service_spec.rb b/spec/services/service_ping/permit_data_categories_service_spec.rb
index 4fd5c6f9ccb..550c0ea5e13 100644
--- a/spec/services/service_ping/permit_data_categories_service_spec.rb
+++ b/spec/services/service_ping/permit_data_categories_service_spec.rb
@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe ServicePing::PermitDataCategoriesService do
- using RSpec::Parameterized::TableSyntax
-
describe '#execute', :without_license do
subject(:permitted_categories) { described_class.new.execute }
@@ -15,7 +13,7 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
end
it 'returns all categories' do
- expect(permitted_categories).to match_array(%w[Standard Subscription Operational Optional])
+ expect(permitted_categories).to match_array(%w[standard subscription operational optional])
end
end
@@ -41,27 +39,4 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
end
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
-
- # 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
-
- 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
diff --git a/spec/services/service_ping/service_ping_settings_spec.rb b/spec/services/service_ping/service_ping_settings_spec.rb
new file mode 100644
index 00000000000..90a5c6b30eb
--- /dev/null
+++ b/spec/services/service_ping/service_ping_settings_spec.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+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
+ # Usage ping enabled
+ true | false | true
+ true | true | false
+
+ # 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
+
+ it 'has the correct product_intelligence_enabled?' do
+ expect(described_class.product_intelligence_enabled?).to eq(expected_product_intelligence_enabled)
+ end
+ end
+ end
+
+ describe '#enabled?' do
+ describe 'has the correct enabled' do
+ it 'when false' do
+ stub_config_setting(usage_ping_enabled: false)
+
+ expect(described_class.enabled?).to eq(false)
+ end
+
+ it 'when true' do
+ stub_config_setting(usage_ping_enabled: true)
+
+ expect(described_class.enabled?).to eq(true)
+ end
+ 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 8a3065e6bc6..05df4e49014 100644
--- a/spec/services/service_ping/submit_service_ping_service_spec.rb
+++ b/spec/services/service_ping/submit_service_ping_service_spec.rb
@@ -100,9 +100,7 @@ RSpec.describe ServicePing::SubmitService do
context 'when product_intelligence_enabled is false' do
before do
- allow_next_instance_of(ServicePing::PermitDataCategoriesService) do |service|
- allow(service).to receive(:product_intelligence_enabled?).and_return(false)
- end
+ allow(ServicePing::ServicePingSettings).to receive(:product_intelligence_enabled?).and_return(false)
end
it_behaves_like 'does not run'
@@ -112,9 +110,7 @@ RSpec.describe ServicePing::SubmitService do
before do
stub_usage_data_connections
- allow_next_instance_of(ServicePing::PermitDataCategoriesService) do |service|
- allow(service).to receive(:product_intelligence_enabled?).and_return(true)
- end
+ allow(ServicePing::ServicePingSettings).to receive(:product_intelligence_enabled?).and_return(true)
end
it 'generates service ping' do