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
5314410c
Commit
5314410c
authored
Sep 17, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Tracing operations service to Core
This commit moves the tracing operations service from Ultimate to Core.
parent
206f145c
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
103 additions
and
103 deletions
+103
-103
app/models/project.rb
app/models/project.rb
+1
-0
app/services/projects/operations/update_service.rb
app/services/projects/operations/update_service.rb
+10
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+0
-1
ee/app/services/ee/projects/operations/update_service.rb
ee/app/services/ee/projects/operations/update_service.rb
+0
-10
ee/spec/services/projects/operations/update_service_spec.rb
ee/spec/services/projects/operations/update_service_spec.rb
+2
-90
spec/services/projects/operations/update_service_spec.rb
spec/services/projects/operations/update_service_spec.rb
+90
-2
No files found.
app/models/project.rb
View file @
5314410c
...
...
@@ -366,6 +366,7 @@ class Project < ApplicationRecord
allow_destroy:
true
,
reject_if:
->
(
attrs
)
{
attrs
[
:id
].
blank?
&&
attrs
[
:url
].
blank?
}
accepts_nested_attributes_for
:tracing_setting
,
update_only:
true
,
allow_destroy:
true
accepts_nested_attributes_for
:incident_management_setting
,
update_only:
true
accepts_nested_attributes_for
:error_tracking_setting
,
update_only:
true
accepts_nested_attributes_for
:metrics_setting
,
update_only:
true
,
allow_destroy:
true
...
...
app/services/projects/operations/update_service.rb
View file @
5314410c
...
...
@@ -18,6 +18,7 @@ module Projects
.
merge
(
grafana_integration_params
)
.
merge
(
prometheus_integration_params
)
.
merge
(
incident_management_setting_params
)
.
merge
(
tracing_setting_params
)
end
def
alerting_setting_params
...
...
@@ -121,6 +122,15 @@ module Projects
{
incident_management_setting_attributes:
attrs
}
end
def
tracing_setting_params
attr
=
params
[
:tracing_setting_attributes
]
return
{}
unless
attr
destroy
=
attr
[
:external_url
].
blank?
{
tracing_setting_attributes:
attr
.
merge
(
_destroy:
destroy
)
}
end
end
end
end
...
...
ee/app/models/ee/project.rb
View file @
5314410c
...
...
@@ -186,7 +186,6 @@ module EE
validates
:mirror_user
,
presence:
true
end
accepts_nested_attributes_for
:tracing_setting
,
update_only:
true
,
allow_destroy:
true
accepts_nested_attributes_for
:status_page_setting
,
update_only:
true
,
allow_destroy:
true
accepts_nested_attributes_for
:compliance_framework_setting
,
update_only:
true
,
allow_destroy:
true
...
...
ee/app/services/ee/projects/operations/update_service.rb
View file @
5314410c
...
...
@@ -10,21 +10,11 @@ module EE
override
:project_update_params
def
project_update_params
super
.
merge
(
tracing_setting_params
)
.
merge
(
status_page_setting_params
)
end
private
def
tracing_setting_params
attr
=
params
[
:tracing_setting_attributes
]
return
{}
unless
attr
destroy
=
attr
[
:external_url
].
blank?
{
tracing_setting_attributes:
attr
.
merge
(
_destroy:
destroy
)
}
end
def
status_page_setting_params
return
{}
unless
attrs
=
params
[
:status_page_setting_attributes
]
...
...
ee/spec/services/projects/operations/update_service_spec.rb
View file @
5314410c
...
...
@@ -3,104 +3,16 @@
require
'spec_helper'
RSpec
.
describe
Projects
::
Operations
::
UpdateService
do
let_it_be_with_refind
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:result
)
{
subject
.
execute
}
subject
{
described_class
.
new
(
project
,
user
,
params
)
}
describe
'#execute'
do
context
'tracing setting'
do
context
'with valid params'
do
let
(
:params
)
do
{
tracing_setting_attributes:
{
external_url:
'http://some-url.com'
}
}
end
context
'with an existing setting'
do
before
do
create
(
:project_tracing_setting
,
project:
project
)
end
shared_examples
'setting deletion'
do
let!
(
:original_params
)
{
params
.
deep_dup
}
it
'deletes the setting'
do
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
reload
.
tracing_setting
).
to
be_nil
end
it
'does not modify original params'
do
subject
.
execute
expect
(
params
).
to
eq
(
original_params
)
end
end
it
'updates the setting'
do
expect
(
project
.
tracing_setting
).
not_to
be_nil
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
reload
.
tracing_setting
.
external_url
)
.
to
eq
(
'http://some-url.com'
)
end
context
'with missing external_url'
do
before
do
params
[
:tracing_setting_attributes
].
delete
(
:external_url
)
end
it_behaves_like
'setting deletion'
end
context
'with empty external_url'
do
before
do
params
[
:tracing_setting_attributes
][
:external_url
]
=
''
end
it_behaves_like
'setting deletion'
end
context
'with blank external_url'
do
before
do
params
[
:tracing_setting_attributes
][
:external_url
]
=
' '
end
it_behaves_like
'setting deletion'
end
end
context
'without an existing setting'
do
it
'creates a setting'
do
expect
(
project
.
tracing_setting
).
to
be_nil
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
reload
.
tracing_setting
.
external_url
)
.
to
eq
(
'http://some-url.com'
)
end
end
end
context
'with empty params'
do
let
(
:params
)
{
{}
}
let!
(
:tracing_setting
)
do
create
(
:project_tracing_setting
,
project:
project
)
end
it
'does nothing'
do
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
reload
.
tracing_setting
).
to
eq
(
tracing_setting
)
end
end
end
context
'status page setting'
do
before
do
before
_all
do
project
.
add_maintainer
(
user
)
end
...
...
spec/services/projects/operations/update_service_spec.rb
View file @
5314410c
...
...
@@ -3,8 +3,8 @@
require
'spec_helper'
RSpec
.
describe
Projects
::
Operations
::
UpdateService
do
let_it_be_with_refind
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:user
)
{
create
(
:user
)
}
let_it_be
(
:project
,
refind:
true
)
{
create
(
:project
)
}
let
(
:result
)
{
subject
.
execute
}
...
...
@@ -12,7 +12,7 @@ RSpec.describe Projects::Operations::UpdateService do
describe
'#execute'
do
context
'alerting setting'
do
before
do
before
_all
do
project
.
add_maintainer
(
user
)
end
...
...
@@ -430,5 +430,93 @@ RSpec.describe Projects::Operations::UpdateService do
end
end
end
context
'tracing setting'
do
context
'with valid params'
do
let
(
:params
)
do
{
tracing_setting_attributes:
{
external_url:
'http://some-url.com'
}
}
end
context
'with an existing setting'
do
before
do
create
(
:project_tracing_setting
,
project:
project
)
end
shared_examples
'setting deletion'
do
let!
(
:original_params
)
{
params
.
deep_dup
}
it
'deletes the setting'
do
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
reload
.
tracing_setting
).
to
be_nil
end
it
'does not modify original params'
do
subject
.
execute
expect
(
params
).
to
eq
(
original_params
)
end
end
it
'updates the setting'
do
expect
(
project
.
tracing_setting
).
not_to
be_nil
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
reload
.
tracing_setting
.
external_url
)
.
to
eq
(
'http://some-url.com'
)
end
context
'with missing external_url'
do
before
do
params
[
:tracing_setting_attributes
].
delete
(
:external_url
)
end
it_behaves_like
'setting deletion'
end
context
'with empty external_url'
do
before
do
params
[
:tracing_setting_attributes
][
:external_url
]
=
''
end
it_behaves_like
'setting deletion'
end
context
'with blank external_url'
do
before
do
params
[
:tracing_setting_attributes
][
:external_url
]
=
' '
end
it_behaves_like
'setting deletion'
end
end
context
'without an existing setting'
do
it
'creates a setting'
do
expect
(
project
.
tracing_setting
).
to
be_nil
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
reload
.
tracing_setting
.
external_url
)
.
to
eq
(
'http://some-url.com'
)
end
end
end
context
'with empty params'
do
let
(
:params
)
{
{}
}
let!
(
:tracing_setting
)
do
create
(
:project_tracing_setting
,
project:
project
)
end
it
'does nothing'
do
expect
(
result
[
:status
]).
to
eq
(
:success
)
expect
(
project
.
reload
.
tracing_setting
).
to
eq
(
tracing_setting
)
end
end
end
end
end
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