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
549a9afd
Commit
549a9afd
authored
Jul 12, 2021
by
alinamihaila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Submit service ping if product intelligence enabled
parent
17e96ea0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
4 deletions
+92
-4
app/services/service_ping/permit_data_categories_service.rb
app/services/service_ping/permit_data_categories_service.rb
+2
-2
app/services/service_ping/submit_service.rb
app/services/service_ping/submit_service.rb
+1
-2
ee/spec/services/ee/service_ping/permit_data_categories_service_spec.rb
...es/ee/service_ping/permit_data_categories_service_spec.rb
+36
-0
spec/services/service_ping/permit_data_categories_service_spec.rb
...vices/service_ping/permit_data_categories_service_spec.rb
+25
-0
spec/services/service_ping/submit_service_ping_service_spec.rb
...services/service_ping/submit_service_ping_service_spec.rb
+28
-0
No files found.
app/services/service_ping/permit_data_categories_service.rb
View file @
549a9afd
...
@@ -19,12 +19,12 @@ module ServicePing
...
@@ -19,12 +19,12 @@ module ServicePing
CATEGORIES
CATEGORIES
end
end
private
def
product_intelligence_enabled?
def
product_intelligence_enabled?
pings_enabled?
&&
!
User
.
single_user
&
.
requires_usage_stats_consent?
pings_enabled?
&&
!
User
.
single_user
&
.
requires_usage_stats_consent?
end
end
private
def
pings_enabled?
def
pings_enabled?
::
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
::
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
end
end
...
...
app/services/service_ping/submit_service.rb
View file @
549a9afd
...
@@ -18,8 +18,7 @@ module ServicePing
...
@@ -18,8 +18,7 @@ module ServicePing
SubmissionError
=
Class
.
new
(
StandardError
)
SubmissionError
=
Class
.
new
(
StandardError
)
def
execute
def
execute
return
unless
Gitlab
::
CurrentSettings
.
usage_ping_enabled?
return
unless
ServicePing
::
PermitDataCategoriesService
.
new
.
product_intelligence_enabled?
return
if
User
.
single_user
&
.
requires_usage_stats_consent?
usage_data
=
Gitlab
::
UsageData
.
data
(
force_refresh:
true
)
usage_data
=
Gitlab
::
UsageData
.
data
(
force_refresh:
true
)
...
...
ee/spec/services/ee/service_ping/permit_data_categories_service_spec.rb
View file @
549a9afd
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
ServicePing
::
PermitDataCategoriesService
do
RSpec
.
describe
ServicePing
::
PermitDataCategoriesService
do
using
RSpec
::
Parameterized
::
TableSyntax
describe
'#execute'
do
describe
'#execute'
do
subject
(
:permitted_categories
)
{
described_class
.
new
.
execute
}
subject
(
:permitted_categories
)
{
described_class
.
new
.
execute
}
...
@@ -96,4 +98,38 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
...
@@ -96,4 +98,38 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
end
end
end
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
(
usage_ping_required_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
end
spec/services/service_ping/permit_data_categories_service_spec.rb
View file @
549a9afd
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
ServicePing
::
PermitDataCategoriesService
do
RSpec
.
describe
ServicePing
::
PermitDataCategoriesService
do
using
RSpec
::
Parameterized
::
TableSyntax
describe
'#execute'
,
:without_license
do
describe
'#execute'
,
:without_license
do
subject
(
:permitted_categories
)
{
described_class
.
new
.
execute
}
subject
(
:permitted_categories
)
{
described_class
.
new
.
execute
}
...
@@ -39,4 +41,27 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
...
@@ -39,4 +41,27 @@ RSpec.describe ServicePing::PermitDataCategoriesService do
end
end
end
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
end
spec/services/service_ping/submit_service_ping_service_spec.rb
View file @
549a9afd
...
@@ -98,6 +98,34 @@ RSpec.describe ServicePing::SubmitService do
...
@@ -98,6 +98,34 @@ RSpec.describe ServicePing::SubmitService do
it_behaves_like
'does not run'
it_behaves_like
'does not run'
end
end
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
end
it_behaves_like
'does not run'
end
context
'when product_intelligence_enabled is true'
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
end
it
'generates service ping'
do
stub_response
(
body:
with_dev_ops_score_params
)
expect
(
Gitlab
::
UsageData
).
to
receive
(
:data
).
with
(
force_refresh:
true
).
and_call_original
subject
.
execute
end
end
context
'when usage ping is enabled'
do
context
'when usage ping is enabled'
do
before
do
before
do
stub_usage_data_connections
stub_usage_data_connections
...
...
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