Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a3246c17
Commit
a3246c17
authored
Jul 15, 2021
by
Rajendra Kadam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix specs and remove prepend
parent
41a46db7
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
97 additions
and
72 deletions
+97
-72
app/services/service_ping/service_ping_settings.rb
app/services/service_ping/service_ping_settings.rb
+2
-0
app/services/service_ping/submit_service.rb
app/services/service_ping/submit_service.rb
+1
-1
ee/app/services/ee/service_ping/permit_data_categories_service.rb
...ervices/ee/service_ping/permit_data_categories_service.rb
+1
-8
ee/app/services/ee/service_ping/service_ping_settings.rb
ee/app/services/ee/service_ping/service_ping_settings.rb
+19
-0
ee/spec/services/ee/service_ping/permit_data_categories_service_spec.rb
...es/ee/service_ping/permit_data_categories_service_spec.rb
+1
-34
ee/spec/services/ee/service_ping/service_ping_settings_spec.rb
...ec/services/ee/service_ping/service_ping_settings_spec.rb
+41
-0
spec/services/service_ping/permit_data_categories_service_spec.rb
...vices/service_ping/permit_data_categories_service_spec.rb
+0
-23
spec/services/service_ping/service_ping_settings_spec.rb
spec/services/service_ping/service_ping_settings_spec.rb
+30
-0
spec/services/service_ping/submit_service_ping_service_spec.rb
...services/service_ping/submit_service_ping_service_spec.rb
+2
-6
No files found.
app/services/service_ping/service_ping_settings.rb
View file @
a3246c17
...
...
@@ -7,6 +7,8 @@ module ServicePing
pings_enabled?
&&
!
User
.
single_user
&
.
requires_usage_stats_consent?
end
private
def
pings_enabled?
::
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
end
...
...
app/services/service_ping/submit_service.rb
View file @
a3246c17
...
...
@@ -18,7 +18,7 @@ module ServicePing
SubmissionError
=
Class
.
new
(
StandardError
)
def
execute
return
unless
ServicePing
::
PermitDataCategoriesService
.
new
.
product_intelligence_enabled?
return
unless
ServicePing
::
ServicePingSettings
.
product_intelligence_enabled?
begin
usage_data
=
BuildPayloadService
.
new
.
execute
...
...
ee/app/services/ee/service_ping/permit_data_categories_service.rb
View file @
a3246c17
...
...
@@ -13,7 +13,7 @@ module EE
override
:execute
def
execute
return
super
unless
::
License
.
current
.
present?
return
[]
unless
product_intelligence_enabled?
return
[]
unless
ServicePing
::
ServicePingSettings
.
product_intelligence_enabled?
optional_enabled
=
::
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
customer_service_enabled
=
::
License
.
current
.
customer_service_enabled?
...
...
@@ -23,13 +23,6 @@ module EE
categories
<<
OPERATIONAL_CATEGORY
if
customer_service_enabled
end
.
to_set
end
private
override
:pings_enabled?
def
pings_enabled?
::
License
.
current
&
.
customer_service_enabled?
||
super
end
end
end
end
ee/app/services/ee/service_ping/service_ping_settings.rb
0 → 100644
View file @
a3246c17
# frozen_string_literal: true
module
EE
module
ServicePing
module
ServicePingSettings
class
<<
self
def
product_intelligence_enabled?
pings_enabled?
&&
!::
User
.
single_user
&
.
requires_usage_stats_consent?
end
private
def
pings_enabled?
::
License
.
current
&
.
customer_service_enabled?
||
::
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
end
end
end
end
end
ee/spec/services/ee/service_ping/permit_data_categories_service_spec.rb
View file @
a3246c17
...
...
@@ -78,6 +78,7 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
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
)
end
it
'returns all categories'
do
...
...
@@ -98,38 +99,4 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
end
end
end
describe
'#product_intelligence_enabled?'
do
where
(
:usage_ping_enabled
,
:customer_service_enabled
,
:requires_usage_stats_consent
,
:expected_product_intelligence_enabled
)
do
# Customer service enabled
true
|
true
|
false
|
true
false
|
true
|
true
|
false
false
|
true
|
false
|
true
true
|
true
|
true
|
false
# Customer service disabled
true
|
false
|
false
|
true
true
|
false
|
true
|
false
false
|
false
|
false
|
false
false
|
false
|
true
|
false
# When there is no license it should have same behaviour as ce
true
|
nil
|
false
|
true
false
|
nil
|
false
|
false
false
|
nil
|
true
|
false
true
|
nil
|
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
)
create_current_license
(
operational_metrics_enabled:
customer_service_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
ee/spec/services/ee/service_ping/service_ping_settings_spec.rb
0 → 100644
View file @
a3246c17
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
EE
::
ServicePing
::
ServicePingSettings
do
using
RSpec
::
Parameterized
::
TableSyntax
describe
'#product_intelligence_enabled?'
do
where
(
:usage_ping_enabled
,
:customer_service_enabled
,
:requires_usage_stats_consent
,
:expected_product_intelligence_enabled
)
do
# Customer service enabled
true
|
true
|
false
|
true
false
|
true
|
true
|
false
false
|
true
|
false
|
true
true
|
true
|
true
|
false
# Customer service disabled
true
|
false
|
false
|
true
true
|
false
|
true
|
false
false
|
false
|
false
|
false
false
|
false
|
true
|
false
# When there is no license it should have same behaviour as ce
true
|
nil
|
false
|
true
false
|
nil
|
false
|
false
false
|
nil
|
true
|
false
true
|
nil
|
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
)
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
)
end
end
end
end
spec/services/service_ping/permit_data_categories_service_spec.rb
View file @
a3246c17
...
...
@@ -41,27 +41,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
spec/services/service_ping/service_ping_settings_spec.rb
View file @
a3246c17
# 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
end
spec/services/service_ping/submit_service_ping_service_spec.rb
View file @
a3246c17
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment